Loading [MathJax]/extensions/tex2jax.js
CTRE Phoenix 6 C++ 25.3.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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/**
21 * Class for CTR Electronics' CANdi™ branded device,
22 * a device that integrates digital signals into the existing CAN bus network.
23 */
24class CANdi : public core::CoreCANdi,
25 public wpi::Sendable,
26 public wpi::SendableHelper<CANdi>
27{
28 /*
29 * The StatusSignal getters are copies so that calls
30 * to the WPI interface do not update any references
31 *
32 * These are also mutable so the const getter methods are
33 * properly managed.
34 */
35
36 hal::SimDevice m_simCANdi;
37 hal::SimDouble m_simSupplyVoltage;
38 hal::SimDouble m_simRequestedOutputCurrent;
39 hal::SimDouble m_simOutputCurrent;
40
41 hal::SimDevice m_simPwm1;
42 hal::SimDouble m_simPwm1Position;
43 hal::SimBoolean m_simPwm1Connected;
44 hal::SimDouble m_simPwm1Velocity;
45 hal::SimDouble m_simPwm1RiseRise;
46 hal::SimDouble m_simPwm1RiseFall;
47
48 hal::SimDevice m_simPwm2;
49 hal::SimDouble m_simPwm2Position;
50 hal::SimBoolean m_simPwm2Connected;
51 hal::SimDouble m_simPwm2Velocity;
52 hal::SimDouble m_simPwm2RiseRise;
53 hal::SimDouble m_simPwm2RiseFall;
54
55 hal::SimDevice m_simQuadrature;
56 hal::SimDouble m_simQuadPos;
57 hal::SimDouble m_simQuadRawPos;
58 hal::SimDouble m_simQuadVel;
59
60 hal::SimDevice m_simS1DIO;
61 hal::SimBoolean m_simS1Closed;
62 hal::SimEnum m_simS1State;
63
64 hal::SimDevice m_simS2DIO;
65 hal::SimBoolean m_simS2Closed;
66 hal::SimEnum m_simS2State;
67
68 int32_t m_simPeriodicUid{-1};
69 std::vector<int32_t> m_simValueChangedUids;
70
71 static void OnValueChanged(const char *name, void *param, HAL_SimValueHandle handle,
72 HAL_Bool readonly, const struct HAL_Value *value);
73 static void OnPeriodic(void *param);
74
75public:
76 /**
77 * Constructs a new CANdi object.
78 *
79 * \param deviceId ID of the device, as configured in Phoenix Tuner.
80 * \param canbus Name of the CAN bus this device is on. Possible CAN bus strings are:
81 * - "rio" for the native roboRIO CAN bus
82 * - CANivore name or serial number
83 * - SocketCAN interface (non-FRC Linux only)
84 * - "*" for any CANivore seen by the program
85 * - empty string (default) to select the default for the system:
86 * - "rio" on roboRIO
87 * - "can0" on Linux
88 * - "*" on Windows
89 */
90 CANdi(int deviceId, std::string canbus = "");
91 /**
92 * Constructs a new CANdi object.
93 *
94 * \param deviceId ID of the device, as configured in Phoenix Tuner.
95 * \param canbus The CAN bus this device is on.
96 */
97 CANdi(int deviceId, CANBus canbus) :
98 CANdi{deviceId, std::string{canbus.GetName()}}
99 {}
100
102
103 void InitSendable(wpi::SendableBuilder &builder) override;
104};
105
106}
107}
108}
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:27
void InitSendable(wpi::SendableBuilder &builder) override
CANdi(int deviceId, CANBus canbus)
Constructs a new CANdi object.
Definition CANdi.hpp:97
CANdi(int deviceId, std::string 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:918
Definition MotionMagicExpoTorqueCurrentFOC.hpp:18
Definition span.hpp:401