CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
CANdi.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Cross The Road Electronics.  All rights reserved.
3 * License information can be found in CTRE_LICENSE.txt
4 * For support and suggestions contact support@ctr-electronics.com or file
5 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
6 */
7#pragma once
8
10
11#include "wpi/sendable/Sendable.h"
12#include "wpi/sendable/SendableBuilder.h"
13#include "wpi/sendable/SendableHelper.h"
14#include <hal/SimDevice.h>
15
16namespace ctre {
17namespace phoenix6 {
18namespace hardware {
19
20#if defined(_WIN32) || defined(_WIN64)
21#pragma warning(push)
22#pragma warning(disable : 4250)
23#endif
24
25/**
26 * Class for CTR Electronics' CANdi™ branded device,
27 * a device that integrates digital signals into the existing CAN bus network.
28 */
29class CANdi : public core::CoreCANdi,
30 public wpi::Sendable,
31 public wpi::SendableHelper<CANdi>
32{
33 /*
34 * The StatusSignal getters are copies so that calls
35 * to the WPI interface do not update any references
36 *
37 * These are also mutable so the const getter methods are
38 * properly managed.
39 */
40
41 hal::SimDevice m_simCANdi;
42 hal::SimDouble m_simSupplyVoltage;
43 hal::SimDouble m_simRequestedOutputCurrent;
44 hal::SimDouble m_simOutputCurrent;
45
46 hal::SimDevice m_simPwm1;
47 hal::SimDouble m_simPwm1Position;
48 hal::SimBoolean m_simPwm1Connected;
49 hal::SimDouble m_simPwm1Velocity;
50 hal::SimDouble m_simPwm1RiseRise;
51 hal::SimDouble m_simPwm1RiseFall;
52
53 hal::SimDevice m_simPwm2;
54 hal::SimDouble m_simPwm2Position;
55 hal::SimBoolean m_simPwm2Connected;
56 hal::SimDouble m_simPwm2Velocity;
57 hal::SimDouble m_simPwm2RiseRise;
58 hal::SimDouble m_simPwm2RiseFall;
59
60 hal::SimDevice m_simQuadrature;
61 hal::SimDouble m_simQuadPos;
62 hal::SimDouble m_simQuadRawPos;
63 hal::SimDouble m_simQuadVel;
64
65 hal::SimDevice m_simS1DIO;
66 hal::SimBoolean m_simS1Closed;
67 hal::SimEnum m_simS1State;
68
69 hal::SimDevice m_simS2DIO;
70 hal::SimBoolean m_simS2Closed;
71 hal::SimEnum m_simS2State;
72
73 int32_t m_simPeriodicUid{-1};
74 std::vector<int32_t> m_simValueChangedUids;
75
76 static void OnValueChanged(
77 const char *name, void *param, HAL_SimValueHandle handle,
78 HAL_Bool readonly, const struct HAL_Value *value
79 );
80 static void OnPeriodic(void *param);
81
82public:
83 /**
84 * Constructs a new CANdi object.
85 *
86 * \param deviceId ID of the device, as configured in Phoenix Tuner
87 * \param canbus The CAN bus this device is on
88 */
89 CANdi(int deviceId, CANBus canbus = {});
90 /**
91 * Constructs a new CANdi object.
92 *
93 * \param deviceId ID of the device, as configured in Phoenix Tuner
94 * \param canbus Name of the CAN bus this device is on. Possible CAN bus strings are:
95 * - "rio" for the native roboRIO CAN bus
96 * - CANivore name or serial number
97 * - SocketCAN interface (non-FRC Linux only)
98 * - "*" for any CANivore seen by the program
99 * - empty string (default) to select the default for the system:
100 * - "rio" on roboRIO
101 * - "can0" on Linux
102 * - "*" on Windows
103 *
104 * \deprecated Constructing devices with a CAN bus string is deprecated for removal
105 * in the 2027 season. Construct devices using a CANBus instance instead.
106 */
107 [[deprecated(
108 "Constructing devices with a CAN bus string is deprecated for removal "
109 "in the 2027 season. Construct devices using a CANBus instance instead."
110 )]]
111 CANdi(int deviceId, std::string canbus);
112
114
115 void InitSendable(wpi::SendableBuilder &builder) override;
116};
117
118#if defined(_WIN32) || defined(_WIN64)
119#pragma warning(pop)
120#endif
121
122}
123}
124}
Class for getting information about an available CAN bus.
Definition CANBus.hpp:19
Class for CTR Electronics' CANdi™ branded device, a device that integrates digital signals into the e...
Definition CANdi.hpp:32
void InitSendable(wpi::SendableBuilder &builder) override
CANdi(int deviceId, std::string canbus)
Constructs a new CANdi object.
CANdi(int deviceId, CANBus canbus={})
Constructs a new CANdi object.
Class for CTR Electronics' CANdi™ branded device, a device that integrates digital signals into the e...
Definition CoreCANdi.hpp:925
Definition motor_constants.h:14