CTRE Phoenix 6 C++ 26.50.0-alpha-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/hal/SimDevice.hpp>
12
13namespace ctre {
14namespace phoenix6 {
15namespace hardware {
16
17#if defined(_WIN32) || defined(_WIN64)
18#pragma warning(push)
19#pragma warning(disable : 4250)
20#endif
21
22/**
23 * Class for CTR Electronics' CANdi™ branded device,
24 * a device that integrates digital signals into the existing CAN bus network.
25 */
26class CANdi : public core::CoreCANdi {
27 /*
28 * The StatusSignal getters are copies so that calls
29 * to the WPI interface do not update any references
30 *
31 * These are also mutable so the const getter methods are
32 * properly managed.
33 */
34
35 wpi::hal::SimDevice m_simCANdi;
36 wpi::hal::SimDouble m_simSupplyVoltage;
37 wpi::hal::SimDouble m_simRequestedOutputCurrent;
38 wpi::hal::SimDouble m_simOutputCurrent;
39
40 wpi::hal::SimDevice m_simPwm1;
41 wpi::hal::SimDouble m_simPwm1Position;
42 wpi::hal::SimBoolean m_simPwm1Connected;
43 wpi::hal::SimDouble m_simPwm1Velocity;
44 wpi::hal::SimDouble m_simPwm1RiseRise;
45 wpi::hal::SimDouble m_simPwm1RiseFall;
46
47 wpi::hal::SimDevice m_simPwm2;
48 wpi::hal::SimDouble m_simPwm2Position;
49 wpi::hal::SimBoolean m_simPwm2Connected;
50 wpi::hal::SimDouble m_simPwm2Velocity;
51 wpi::hal::SimDouble m_simPwm2RiseRise;
52 wpi::hal::SimDouble m_simPwm2RiseFall;
53
54 wpi::hal::SimDevice m_simQuadrature;
55 wpi::hal::SimDouble m_simQuadPos;
56 wpi::hal::SimDouble m_simQuadRawPos;
57 wpi::hal::SimDouble m_simQuadVel;
58
59 wpi::hal::SimDevice m_simS1DIO;
60 wpi::hal::SimBoolean m_simS1Closed;
61 wpi::hal::SimEnum m_simS1State;
62
63 wpi::hal::SimDevice m_simS2DIO;
64 wpi::hal::SimBoolean m_simS2Closed;
65 wpi::hal::SimEnum m_simS2State;
66
67 int32_t m_simPeriodicUid{-1};
68 std::vector<int32_t> m_simValueChangedUids;
69
70 static void OnValueChanged(
71 const char *name, void *param, HAL_SimValueHandle handle,
72 HAL_Bool readonly, const struct HAL_Value *value
73 );
74 static void OnPeriodic(void *param);
75
76public:
77 /**
78 * Constructs a new CANdi object.
79 *
80 * \param deviceId ID of the device, as configured in Phoenix Tuner
81 * \param canbus The CAN bus this device is on
82 */
83 CANdi(int deviceId, CANBus canbus);
84
86
87 /**
88 * \brief Constructs a stubbed-out CANdi, where all status signals, controls,
89 * configs, etc. perform no action and immediately return OK. This can be used to
90 * silence error messages for devices that have been completely removed from the robot.
91 *
92 * \returns Stubbed-out CANdi
93 */
94 static CANdi None()
95 {
96 return CANdi{-1, CANBus{}};
97 }
98};
99
100#if defined(_WIN32) || defined(_WIN64)
101#pragma warning(pop)
102#endif
103
104}
105}
106}
Class for getting information about an available CAN bus.
Definition CANBus.hpp:19
CANdi(int deviceId, CANBus canbus)
Constructs a new CANdi object.
static CANdi None()
Constructs a stubbed-out CANdi, where all status signals, controls, configs, etc.
Definition CANdi.hpp:94
Class for CTR Electronics' CANdi™ branded device, a device that integrates digital signals into the e...
Definition CoreCANdi.hpp:924
Definition ExternalFeedbackConfigs.hpp:17
Definition ExternalFeedbackConfigs.hpp:16
Definition motor_constants.h:14