21#include <units/angle.h>
22#include <units/angular_velocity.h>
23#include <units/current.h>
24#include <units/time.h>
25#include <units/voltage.h>
246 PWM1 = std::move(newPWM1);
274 PWM2 = std::move(newPWM2);
321 return Apply(configs, DefaultTimeoutSeconds);
350 return Apply(configs, DefaultTimeoutSeconds);
364 return SetConfigsPrivate(configs.
Serialize(), timeoutSeconds,
false,
false);
379 return Apply(configs, DefaultTimeoutSeconds);
393 return SetConfigsPrivate(configs.
Serialize(), timeoutSeconds,
false,
false);
408 return Apply(configs, DefaultTimeoutSeconds);
422 return SetConfigsPrivate(configs.
Serialize(), timeoutSeconds,
false,
false);
437 return Apply(configs, DefaultTimeoutSeconds);
451 return SetConfigsPrivate(configs.
Serialize(), timeoutSeconds,
false,
false);
466 return Apply(configs, DefaultTimeoutSeconds);
480 return SetConfigsPrivate(configs.
Serialize(), timeoutSeconds,
false,
false);
495 return Refresh(configs, DefaultTimeoutSeconds);
527 return Refresh(configs, DefaultTimeoutSeconds);
558 return Refresh(configs, DefaultTimeoutSeconds);
589 return Refresh(configs, DefaultTimeoutSeconds);
620 return Refresh(configs, DefaultTimeoutSeconds);
651 return Refresh(configs, DefaultTimeoutSeconds);
687 return SetQuadraturePosition(newValue, DefaultTimeoutSeconds);
723 return ClearStickyFaults(DefaultTimeoutSeconds);
758 return ClearStickyFault_Hardware(DefaultTimeoutSeconds);
790 return ClearStickyFault_Undervoltage(DefaultTimeoutSeconds);
823 return ClearStickyFault_BootDuringEnable(DefaultTimeoutSeconds);
856 return ClearStickyFault_UnlicensedFeatureInUse(DefaultTimeoutSeconds);
890 return ClearStickyFault_5V(DefaultTimeoutSeconds);
914#if defined(_WIN32) || defined(_WIN64)
916#pragma warning(disable : 4250)
999 std::unique_ptr<sim::CANdiSimState> _simState{};
1012 if (_simState ==
nullptr)
1013 _simState = std::make_unique<sim::CANdiSimState>(*
this);
1655 return GetConfigurator().SetQuadraturePosition(newValue, timeoutSeconds);
1667 return SetQuadraturePosition(newValue, 0.100_s);
1682 return GetConfigurator().ClearStickyFaults(timeoutSeconds);
1697 return ClearStickyFaults(0.100_s);
1708 return GetConfigurator().ClearStickyFault_Hardware(timeoutSeconds);
1719 return ClearStickyFault_Hardware(0.100_s);
1731 return GetConfigurator().ClearStickyFault_Undervoltage(timeoutSeconds);
1743 return ClearStickyFault_Undervoltage(0.100_s);
1755 return GetConfigurator().ClearStickyFault_BootDuringEnable(timeoutSeconds);
1767 return ClearStickyFault_BootDuringEnable(0.100_s);
1779 return GetConfigurator().ClearStickyFault_UnlicensedFeatureInUse(timeoutSeconds);
1791 return ClearStickyFault_UnlicensedFeatureInUse(0.100_s);
1804 return GetConfigurator().ClearStickyFault_5V(timeoutSeconds);
1817 return ClearStickyFault_5V(0.100_s);
1821#if defined(_WIN32) || defined(_WIN64)
Class for getting information about an available CAN bus.
Definition CANBus.hpp:19
Represents a status signal with data of type T, and operations available to retrieve information abou...
Definition StatusSignal.hpp:567
Class for CTR Electronics' CANdi™ branded device, a device that integrates digital signals into the e...
Definition CoreCANdi.hpp:45
QuadratureConfigs Quadrature
Configs related to the CANdi™ branded device's quadrature interface using both the S1IN and S2IN inpu...
Definition CoreCANdi.hpp:109
std::string Serialize() const final
Get the serialized form of this configuration.
bool FutureProofConfigs
True if we should factory default newer unsupported configs, false to leave newer unsupported configs...
Definition CoreCANdi.hpp:62
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
Take a string and deserialize it to this configuration.
constexpr CANdiConfiguration & WithPWM1(PWM1Configs newPWM1)
Modifies this configuration's PWM1 parameter and returns itself for method-chaining and easier to use...
Definition CoreCANdi.hpp:244
PWM2Configs PWM2
Configs related to the CANdi™ branded device's PWM interface on the Signal 2 input (S2IN)
Definition CoreCANdi.hpp:145
constexpr CANdiConfiguration & WithCustomParams(CustomParamsConfigs newCustomParams)
Modifies this configuration's CustomParams parameter and returns itself for method-chaining and easie...
Definition CoreCANdi.hpp:164
DigitalInputsConfigs DigitalInputs
Configs related to the CANdi™ branded device's digital I/O settings.
Definition CoreCANdi.hpp:93
std::string ToString() const override
Get the string representation of this configuration.
constexpr CANdiConfiguration & WithDigitalInputs(DigitalInputsConfigs newDigitalInputs)
Modifies this configuration's DigitalInputs parameter and returns itself for method-chaining and easi...
Definition CoreCANdi.hpp:190
constexpr CANdiConfiguration()=default
CustomParamsConfigs CustomParams
Custom Params.
Definition CoreCANdi.hpp:76
constexpr CANdiConfiguration & WithPWM2(PWM2Configs newPWM2)
Modifies this configuration's PWM2 parameter and returns itself for method-chaining and easier to use...
Definition CoreCANdi.hpp:272
constexpr CANdiConfiguration & WithQuadrature(QuadratureConfigs newQuadrature)
Modifies this configuration's Quadrature parameter and returns itself for method-chaining and easier ...
Definition CoreCANdi.hpp:216
PWM1Configs PWM1
Configs related to the CANdi™ branded device's PWM interface on the Signal 1 input (S1IN)
Definition CoreCANdi.hpp:127
Class for CTR Electronics' CANdi™ branded device, a device that integrates digital signals into the e...
Definition CoreCANdi.hpp:300
ctre::phoenix::StatusCode Refresh(QuadratureConfigs &configs, units::time::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:600
ctre::phoenix::StatusCode Refresh(CustomParamsConfigs &configs, units::time::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:538
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse(units::time::second_t timeoutSeconds)
Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
ctre::phoenix::StatusCode ClearStickyFault_Hardware()
Clear sticky fault: Hardware fault occurred.
Definition CoreCANdi.hpp:756
ctre::phoenix::StatusCode Refresh(PWM1Configs &configs, units::time::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:631
ctre::phoenix::StatusCode Apply(const QuadratureConfigs &configs)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:406
ctre::phoenix::StatusCode SetQuadraturePosition(units::angle::turn_t newValue)
Sets the position of the quadrature input.
Definition CoreCANdi.hpp:685
ctre::phoenix::StatusCode Apply(const DigitalInputsConfigs &configs, units::time::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:391
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable(units::time::second_t timeoutSeconds)
Clear sticky fault: Device boot while detecting the enable signal.
ctre::phoenix::StatusCode Refresh(DigitalInputsConfigs &configs) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:556
ctre::phoenix::StatusCode Apply(const CustomParamsConfigs &configs, units::time::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:362
ctre::phoenix::StatusCode Refresh(CANdiConfiguration &configs, units::time::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:507
ctre::phoenix::StatusCode Apply(const PWM1Configs &configs)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:435
ctre::phoenix::StatusCode ClearStickyFault_Hardware(units::time::second_t timeoutSeconds)
Clear sticky fault: Hardware fault occurred.
ctre::phoenix::StatusCode SetQuadraturePosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
Sets the position of the quadrature input.
ctre::phoenix::StatusCode Apply(const PWM1Configs &configs, units::time::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:449
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage()
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition CoreCANdi.hpp:788
ctre::phoenix::StatusCode Refresh(QuadratureConfigs &configs) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:587
ctre::phoenix::StatusCode Apply(const QuadratureConfigs &configs, units::time::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:420
ctre::phoenix::StatusCode Apply(const CANdiConfiguration &configs)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:319
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage(units::time::second_t timeoutSeconds)
Clear sticky fault: Device supply voltage dropped to near brownout levels.
ctre::phoenix::StatusCode Apply(const PWM2Configs &configs, units::time::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:478
ctre::phoenix::StatusCode ClearStickyFaults(units::time::second_t timeoutSeconds)
Clear the sticky faults in the device.
ctre::phoenix::StatusCode ClearStickyFaults()
Clear the sticky faults in the device.
Definition CoreCANdi.hpp:721
ctre::phoenix::StatusCode Refresh(PWM1Configs &configs) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:618
ctre::phoenix::StatusCode Refresh(CANdiConfiguration &configs) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:493
ctre::phoenix::StatusCode Refresh(CustomParamsConfigs &configs) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:525
ctre::phoenix::StatusCode Apply(const DigitalInputsConfigs &configs)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:377
ctre::phoenix::StatusCode Refresh(PWM2Configs &configs) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:649
ctre::phoenix::StatusCode Apply(const PWM2Configs &configs)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:464
ctre::phoenix::StatusCode ClearStickyFault_5V()
Clear sticky fault: The CTR Electronics' CANdi™ branded device has detected a 5V fault.
Definition CoreCANdi.hpp:888
ctre::phoenix::StatusCode Apply(const CustomParamsConfigs &configs)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:348
ctre::phoenix::StatusCode Refresh(PWM2Configs &configs, units::time::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:662
ctre::phoenix::StatusCode ClearStickyFault_5V(units::time::second_t timeoutSeconds)
Clear sticky fault: The CTR Electronics' CANdi™ branded device has detected a 5V fault.
ctre::phoenix::StatusCode Refresh(DigitalInputsConfigs &configs, units::time::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:569
ctre::phoenix::StatusCode Apply(const CANdiConfiguration &configs, units::time::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:333
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable()
Clear sticky fault: Device boot while detecting the enable signal.
Definition CoreCANdi.hpp:821
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse()
Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
Definition CoreCANdi.hpp:854
Custom Params.
Definition CustomParamsConfigs.hpp:23
std::string Serialize() const final
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
Configs related to the CANdi™ branded device's PWM interface on the Signal 1 input (S1IN)
Definition PWM1Configs.hpp:27
std::string Serialize() const final
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
Configs related to the CANdi™ branded device's PWM interface on the Signal 2 input (S2IN)
Definition PWM2Configs.hpp:27
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
std::string Serialize() const final
Definition Configuration.hpp:17
The base class for all device configurators.
Definition Configurator.hpp:21
Configs related to the CANdi™ branded device's quadrature interface using both the S1IN and S2IN inpu...
Definition QuadratureConfigs.hpp:26
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
std::string Serialize() const final
The unique identifier for a device.
Definition DeviceIdentifier.hpp:19
Parent class for all devices.
Definition ParentDevice.hpp:23
Class for CTR Electronics' CANdi™ branded device, a device that integrates digital signals into the e...
Definition CoreCANdi.hpp:924
ctre::phoenix::StatusCode SetQuadraturePosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
Sets the position of the quadrature input.
Definition CoreCANdi.hpp:1653
StatusSignal< bool > & GetFault_Hardware(bool refresh=true)
Hardware fault occurred.
configs::CANdiConfigurator const & GetConfigurator() const
Gets the configurator for this CANdi.
Definition CoreCANdi.hpp:992
StatusSignal< bool > & GetStickyFault_BootDuringEnable(bool refresh=true)
Device boot while detecting the enable signal.
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable(units::time::second_t timeoutSeconds)
Clear sticky fault: Device boot while detecting the enable signal.
Definition CoreCANdi.hpp:1753
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse(units::time::second_t timeoutSeconds)
Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
Definition CoreCANdi.hpp:1777
StatusSignal< units::time::microsecond_t > & GetPWM2RiseToRise(bool refresh=true)
Measured rise to rise time of the PWM signal at the S2 input of the CTR Electronics' CANdi™.
ctre::phoenix::StatusCode ClearStickyFault_Hardware(units::time::second_t timeoutSeconds)
Clear sticky fault: Hardware fault occurred.
Definition CoreCANdi.hpp:1706
StatusSignal< bool > & GetFault_5V(bool refresh=true)
The CTR Electronics' CANdi™ branded device has detected a 5V fault.
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage()
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition CoreCANdi.hpp:1741
StatusSignal< int > & GetVersionBuild(bool refresh=true)
App Build Version number.
ctre::phoenix::StatusCode ClearStickyFault_5V(units::time::second_t timeoutSeconds)
Clear sticky fault: The CTR Electronics' CANdi™ branded device has detected a 5V fault.
Definition CoreCANdi.hpp:1802
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage(units::time::second_t timeoutSeconds)
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition CoreCANdi.hpp:1729
StatusSignal< bool > & GetS2Closed(bool refresh=true)
True if the Signal 2 input (S2IN) matches the configured S2 Closed State.
StatusSignal< units::angular_velocity::turns_per_second_t > & GetPWM2Velocity(bool refresh=true)
Measured velocity of the PWM sensor at the S2 input of the CTR Electronics' CANdi™.
sim::CANdiSimState & GetSimState()
Get the simulation state for this device.
Definition CoreCANdi.hpp:1010
StatusSignal< int > & GetVersionBugfix(bool refresh=true)
App Bugfix Version number.
StatusSignal< bool > & GetStickyFault_Undervoltage(bool refresh=true)
Device supply voltage dropped to near brownout levels.
StatusSignal< bool > & GetStickyFault_5V(bool refresh=true)
The CTR Electronics' CANdi™ branded device has detected a 5V fault.
StatusSignal< bool > & GetFault_UnlicensedFeatureInUse(bool refresh=true)
An unlicensed feature is in use, device may not behave as expected.
StatusSignal< bool > & GetFault_Undervoltage(bool refresh=true)
Device supply voltage dropped to near brownout levels.
configs::CANdiConfigurator & GetConfigurator()
Gets the configurator for this CANdi.
Definition CoreCANdi.hpp:980
StatusSignal< signals::S1StateValue > & GetS1State(bool refresh=true)
State of the Signal 1 input (S1IN).
StatusSignal< units::voltage::volt_t > & GetSupplyVoltage(bool refresh=true)
Measured supply voltage to the CANdi™.
StatusSignal< int > & GetVersion(bool refresh=true)
Full Version of firmware in device.
StatusSignal< bool > & GetStickyFault_UnlicensedFeatureInUse(bool refresh=true)
An unlicensed feature is in use, device may not behave as expected.
StatusSignal< units::time::microsecond_t > & GetPWM1RiseToRise(bool refresh=true)
Measured rise to rise time of the PWM signal at the S1 input of the CTR Electronics' CANdi™.
StatusSignal< int > & GetStickyFaultField(bool refresh=true)
Integer representing all (persistent) sticky fault flags reported by the device.
StatusSignal< bool > & GetIsProLicensed(bool refresh=true)
Whether the device is Phoenix Pro licensed.
ctre::phoenix::StatusCode ClearStickyFaults(units::time::second_t timeoutSeconds)
Clear the sticky faults in the device.
Definition CoreCANdi.hpp:1680
ctre::phoenix::StatusCode ClearStickyFaults()
Clear the sticky faults in the device.
Definition CoreCANdi.hpp:1695
StatusSignal< int > & GetVersionMajor(bool refresh=true)
App Major Version number.
StatusSignal< bool > & GetOvercurrent(bool refresh=true)
True when the CANdi™ is in overcurrent protection mode.
StatusSignal< int > & GetFaultField(bool refresh=true)
Integer representing all fault flags reported by the device.
ctre::phoenix::StatusCode ClearStickyFault_Hardware()
Clear sticky fault: Hardware fault occurred.
Definition CoreCANdi.hpp:1717
CoreCANdi(int deviceId, std::string canbus)
Constructs a new CANdi object.
StatusSignal< units::angle::turn_t > & GetQuadraturePosition(bool refresh=true)
Position from a quadrature encoder sensor connected to both the S1IN and S2IN inputs.
StatusSignal< units::angle::turn_t > & GetPWM1Position(bool refresh=true)
Measured position of the PWM sensor at the S1 input of the CTR Electronics' CANdi™.
ctre::phoenix::StatusCode SetQuadraturePosition(units::angle::turn_t newValue)
Sets the position of the quadrature input.
Definition CoreCANdi.hpp:1665
StatusSignal< bool > & GetS1Closed(bool refresh=true)
True if the Signal 1 input (S1IN) matches the configured S1 Closed State.
StatusSignal< int > & GetVersionMinor(bool refresh=true)
App Minor Version number.
StatusSignal< bool > & GetStickyFault_Hardware(bool refresh=true)
Hardware fault occurred.
StatusSignal< bool > & GetFault_BootDuringEnable(bool refresh=true)
Device boot while detecting the enable signal.
StatusSignal< signals::S2StateValue > & GetS2State(bool refresh=true)
State of the Signal 2 input (S2IN).
static CoreCANdi None()
Constructs a stubbed-out CoreCANdi, where all status signals, controls, configs, etc.
Definition CoreCANdi.hpp:968
StatusSignal< units::current::ampere_t > & GetOutputCurrent(bool refresh=true)
Measured output current.
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable()
Clear sticky fault: Device boot while detecting the enable signal.
Definition CoreCANdi.hpp:1765
StatusSignal< units::angular_velocity::turns_per_second_t > & GetPWM1Velocity(bool refresh=true)
Measured velocity of the PWM sensor at the S1 input of the CTR Electronics' CANdi™.
ctre::phoenix::StatusCode ClearStickyFault_5V()
Clear sticky fault: The CTR Electronics' CANdi™ branded device has detected a 5V fault.
Definition CoreCANdi.hpp:1815
StatusSignal< units::angle::turn_t > & GetPWM2Position(bool refresh=true)
Measured position of the PWM sensor at the S2 input of the CTR Electronics' CANdi™.
StatusSignal< units::angular_velocity::turns_per_second_t > & GetQuadratureVelocity(bool refresh=true)
Velocity from a quadrature encoder sensor connected to both the S1IN and S2IN inputs.
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse()
Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
Definition CoreCANdi.hpp:1789
CoreCANdi(int deviceId, CANBus canbus={})
Constructs a new CANdi object.
Class to control the state of a simulated hardware::CANdi.
Definition CANdiSimState.hpp:33
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
Definition motor_constants.h:14