CTRE Phoenix C++ 5.33.1
WPI_CANCoder.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2/**
3 * WPI Compliant CANcoder class.
4 * WPILIB's object model requires many interfaces to be implemented to use
5 * the various features.
6 * This includes...
7 * - LiveWindow/Test mode features
8 * - Simulation Hooks
9 */
10
11#pragma once
12
15
16#include <mutex>
17
18//Need to disable certain warnings for WPI headers.
19#if __GNUC__
20#pragma GCC diagnostic push
21#pragma GCC diagnostic ignored "-Wconversion"
22#elif _MSC_VER
23#pragma warning(push)
24#pragma warning(disable : 4522 4458 4522)
25#endif
26
27#include "wpi/sendable/Sendable.h"
28#include "wpi/sendable/SendableHelper.h"
29#include "wpi/raw_ostream.h"
30#include <hal/SimDevice.h>
31
32//Put the warning settings back to normal
33#if __GNUC__
34#pragma GCC diagnostic pop
35#elif _MSC_VER
36#pragma warning(pop)
37#endif
38
39namespace ctre
40{
41namespace phoenix
42{
43namespace sensors
44{
45
46/**
47 * CTRE CANCoder.
48 *
49 * @deprecated This device's Phoenix 5 API is deprecated for removal in the
50 * 2025 season. Users should update to Phoenix 6 firmware and migrate to the
51 * Phoenix 6 API. A migration guide is available at
52 * https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html.
53 *
54 * If the Phoenix 5 API must be used for this device, the device must have 22.X
55 * firmware. This firmware is available in Tuner X after selecting Phoenix 5 in
56 * the firmware year dropdown.
57 */
58class [[deprecated("This device's Phoenix 5 API is deprecated for removal in the 2025 season."
59 "Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API."
60 "A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html")]]
61WPI_CANCoder : public CANCoder,
62 public wpi::Sendable,
63 public wpi::SendableHelper<WPI_CANCoder>
64{
65 public:
66 /**
67 * Construtor for CANCoder.
68 *
69 * @param deviceNumber CAN Device ID of the CANCoder.
70 * @param canbus Name of the CANbus; can be a CANivore device name or serial number.
71 * Pass in nothing or "rio" to use the roboRIO.
72 */
73 WPI_CANCoder(int deviceNumber, std::string const &canbus = "");
74
76
77 WPI_CANCoder() = delete;
78 WPI_CANCoder(WPI_CANCoder const &) = delete;
80
81 void InitSendable(wpi::SendableBuilder& builder) override;
82
83 private:
84
85 hal::SimDevice m_simCANCoder;
86 hal::SimDouble m_simVbat;
87 hal::SimDouble m_simPosition;
88 hal::SimDouble m_simAbsPosition;
89 hal::SimDouble m_simRawPosition;
90 hal::SimDouble m_simVelocity;
91
92 static void OnValueChanged(const char* name, void* param, HAL_SimValueHandle handle,
93 HAL_Bool readonly, const struct HAL_Value* value);
94 static void OnPeriodic(void* param);
95};
96
97} //namespace sensors
98} //namespace phoenix
99} //namespace ctre
CTRE CANCoder.
Definition: CANCoder.h:233
CTRE CANCoder.
Definition: WPI_CANCoder.h:64
WPI_CANCoder(int deviceNumber, std::string const &canbus="")
Construtor for CANCoder.
WPI_CANCoder(WPI_CANCoder const &)=delete
WPI_CANCoder & operator=(WPI_CANCoder const &)=delete
void InitSendable(wpi::SendableBuilder &builder) override
namespace ctre
Definition: paramEnum.h:5