CTRE Phoenix 6 C++ 25.0.0-beta-4
Loading...
Searching...
No Matches
ParentDevice.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
16#include <map>
17#include <memory>
18#include <mutex>
19#include <units/dimensionless.h>
20
21namespace ctre {
22namespace phoenix6 {
23namespace hardware {
24
25 /**
26 * \brief Parent class for all devices
27 */
29 {
30 protected:
32
34
35 /**
36 * \brief Type trait to verify that all types passed in are subclasses of ParentDevice.
37 */
38 template <typename... Devices>
40 std::conjunction<std::is_base_of<ParentDevice, std::remove_reference_t<Devices>>...>
41 {};
42
43 /**
44 * \brief Whether all types passed in are subclasses of ParentDevice.
45 */
46 template <typename... Devices>
47 static constexpr bool is_all_device_v = is_all_device<Devices...>::value;
48
49 private:
50 std::map<uint32_t, std::unique_ptr<BaseStatusSignal>> _signalValues;
51 std::recursive_mutex _signalValuesLck;
52 /*
53 * Use a shared pointer so users that access the control request via #GetAppliedControl has a copy
54 * of the pointer without risk of it becoming a dangling pointer due to parallel operations
55 */
56 std::shared_ptr<controls::ControlRequest> _controlReq = std::make_shared<controls::EmptyControl>();
57 std::mutex _controlReqLck;
58
59 double _creationTime = utils::GetCurrentTimeSeconds();
60
61 bool _isInitialized = false;
63 double _timeToRefreshVersion = utils::GetCurrentTimeSeconds();
64
65 StatusSignal<int> &_compliancy{LookupStatusSignal<int>(ctre::phoenix6::spns::SpnValue::Compliancy_Version, "Compliancy", false, true)};
66 StatusSignal<int> &_resetSignal{LookupStatusSignal<int>(ctre::phoenix6::spns::SpnValue::Startup_ResetFlags, "ResetFlags", false, true)};
67
68 void ReportIfTooOld();
69
70 template <typename T>
71 StatusSignal<T> &LookupCommon(
72 uint16_t spn, std::function<std::map<uint16_t, std::string>()> mapFiller,
73 std::string signalName, bool reportOnConstruction, bool refresh)
74 {
76
77 BaseStatusSignal *toFind;
78 {
79 /* lock access to the map */
80 std::lock_guard<std::recursive_mutex> lock{_signalValuesLck};
81
82 /* lookup and return if found */
83 auto iter = _signalValues.find(spn);
84 if (iter != _signalValues.end()) {
85 /* Found it, toFind is now the found StatusSignal */
86 toFind = iter->second.get();
87 /* since we didn't construct, report errors */
89 } else {
90 /* insert into map */
91 if (!mapFiller) {
92 _signalValues.emplace(spn,
93 std::unique_ptr<StatusSignal<T>>{new StatusSignal<T>{
95 [this] { ReportIfTooOld(); },
96 std::move(signalName)
97 }}
98 );
99 } else {
100 _signalValues.emplace(spn,
101 std::unique_ptr<StatusSignal<T>>{new StatusSignal<T>{
102 deviceIdentifier, spn,
103 [this] { ReportIfTooOld(); },
104 mapFiller, std::move(signalName)
105 }}
106 );
107 }
108
109 /* look up and return */
110 iter = _signalValues.find(spn);
111 toFind = iter->second.get();
112 }
113 }
114
115 /* Now cast it up to the StatusSignal */
116 StatusSignal<T> *ret = dynamic_cast<StatusSignal<T> *>(toFind);
117 /* If ret is null, that means the cast failed. Otherwise we can return it */
118 if (ret == nullptr) {
119 /* Cast failed, let user know this doesn't exist */
120 return failure;
121 } else {
122 /* Good cast, refresh it and return this now */
123 if (refresh) {
124 ret->Refresh(reportOnConstruction);
125 }
126 return *ret;
127 }
128 }
129
130 public:
131 ParentDevice(int deviceID, std::string model, std::string canbus) :
133 {
134 /* This needs to be set to true after everything else has already been initialized */
135 _isInitialized = true;
136 }
137
138 virtual ~ParentDevice() = default;
139
140 ParentDevice(ParentDevice const &) = delete;
142
143 /**
144 * \returns The device ID of this device [0,62].
145 */
146 int GetDeviceID() const
147 {
149 }
150
151 /**
152 * \returns Name of the network this device is on.
153 */
154 const std::string &GetNetwork() const
155 {
157 }
158
159 /**
160 * \brief Gets a number unique for this device's hardware type and ID.
161 * This number is not unique across networks.
162 *
163 * \details This can be used to easily reference hardware devices on
164 * the same network in collections such as maps.
165 *
166 * \returns Hash of this device.
167 */
169 {
171 }
172
173 /**
174 * \brief Get the latest applied control.
175 * Caller can cast this to the derived class if they know its type. Otherwise,
176 * use controls#ControlRequest#GetControlInfo to get info out of it.
177 *
178 * \details This returns a shared pointer to avoid becoming a dangling pointer
179 * due to parallel operations changing the underlying data. Make sure
180 * to save the shared_ptr to a variable before chaining function calls,
181 * otherwise the data may be freed early.
182 *
183 * \returns Latest applied control
184 */
185 std::shared_ptr<const controls::ControlRequest> GetAppliedControl() const
186 {
187 return _controlReq;
188 }
189
190 /**
191 * \brief Get the latest applied control.
192 * Caller can cast this to the derived class if they know its type. Otherwise,
193 * use controls#ControlRequest#GetControlInfo to get info out of it.
194 *
195 * \details This returns a shared pointer to avoid becoming a dangling pointer
196 * due to parallel operations changing the underlying data. Make sure
197 * to save the shared_ptr to a variable before chaining function calls,
198 * otherwise the data may be freed early.
199 *
200 * \returns Latest applied control
201 */
202 std::shared_ptr<controls::ControlRequest> GetAppliedControl()
203 {
204 return _controlReq;
205 }
206
207 /**
208 * \returns true if device has reset since the previous call of this routine.
209 */
211 {
212 return _resetSignal.Refresh(false).HasUpdated();
213 }
214
215 /**
216 * \returns a function that checks for device resets.
217 */
218 std::function<bool()> GetResetOccurredChecker() const
219 {
220 return [resetSignal=_resetSignal]() mutable {
221 return resetSignal.Refresh(false).HasUpdated();
222 };
223 }
224
225 /**
226 * \brief Returns whether the device is still connected to the robot.
227 * This is equivalent to refreshing and checking the latency of the
228 * Version status signal.
229 *
230 * \param maxLatencySeconds The maximum latency of the Version status signal
231 * before the device is reported as disconnected
232 * \returns true if the device is connected
233 */
234 bool IsConnected(units::second_t maxLatencySeconds = 500_ms)
235 {
236 return _compliancy.Refresh(false).GetTimestamp().GetLatency() <= maxLatencySeconds;
237 }
238
239 /**
240 * \brief This is a reserved routine for internal testing. Use the other get routines to retrieve signal values.
241 *
242 * \param signal Signal to get.
243 * \param refresh Whether to refresh
244 * \returns StatusSignalValue holding value
245 */
247 {
248 return LookupStatusSignal<double>((uint16_t)signal, "Generic", true, refresh);
249 }
250
251 /**
252 * \brief Optimizes the device's bus utilization by reducing the update frequencies of its status signals.
253 *
254 * All status signals that have not been explicitly given an update frequency using
255 * BaseStatusSignal#SetUpdateFrequency will be disabled. Note that if other status
256 * signals in the same status frame have been given an update frequency, the update
257 * frequency will be honored for the entire frame.
258 *
259 * This function only needs to be called once on this device in the robot program. Additionally, this
260 * method does not necessarily need to be called after setting the update frequencies of other signals.
261 *
262 * To restore the default status update frequencies, call ResetSignalFrequencies.
263 * Alternatively, remove this method call, redeploy the robot application, and power-cycle
264 * the device on the bus. The user can also override individual status update frequencies
265 * using BaseStatusSignal#SetUpdateFrequency.
266 *
267 * \param optimizedFreqHz The update frequency to apply to the optimized status signals. A frequency of
268 * 0 Hz (default) will turn off the signals. Otherwise, the minimum supported signal
269 * frequency is 4 Hz.
270 * \param timeoutSeconds Maximum amount of time to wait for each status frame when performing the action
271 * \returns Status code of the first failed update frequency set call, or OK if all succeeded
272 */
273 ctre::phoenix::StatusCode OptimizeBusUtilization(units::frequency::hertz_t optimizedFreqHz = 0_Hz, units::time::second_t timeoutSeconds = 100_ms);
274
275 /**
276 * \brief Optimizes the bus utilization of the provided devices by reducing the update
277 * frequencies of their status signals.
278 *
279 * All status signals that have not been explicitly given an update frequency using
280 * BaseStatusSignal#SetUpdateFrequency will be disabled. Note that if other status
281 * signals in the same status frame have been given an update frequency, the update
282 * frequency will be honored for the entire frame.
283 *
284 * This function only needs to be called once in the robot program for the provided devices.
285 * Additionally, this method does not necessarily need to be called after setting the update
286 * frequencies of other signals.
287 *
288 * To restore the default status update frequencies, call ResetSignalFrequenciesForAll.
289 * Alternatively, remove this method call, redeploy the robot application, and power-cycle
290 * the devices on the bus. The user can also override individual status update frequencies
291 * using BaseStatusSignal#SetUpdateFrequency.
292 *
293 * This will wait up to 0.100 seconds (100ms) for each status frame.
294 *
295 * \param devices Devices for which to optimize bus utilization, passed as a comma-separated list of device references.
296 * \returns Status code of the first failed optimize call, or OK if all succeeded
297 */
298 template <typename... Devices, typename = std::enable_if_t<is_all_device_v<Devices...>>>
300 {
301 return OptimizeBusUtilizationForAll(0_Hz, devices...);
302 }
303
304 /**
305 * \brief Optimizes the bus utilization of the provided devices by reducing the update
306 * frequencies of their status signals.
307 *
308 * All status signals that have not been explicitly given an update frequency using
309 * BaseStatusSignal#SetUpdateFrequency will be disabled. Note that if other status
310 * signals in the same status frame have been given an update frequency, the update
311 * frequency will be honored for the entire frame.
312 *
313 * This function only needs to be called once in the robot program for the provided devices.
314 * Additionally, this method does not necessarily need to be called after setting the update
315 * frequencies of other signals.
316 *
317 * To restore the default status update frequencies, call ResetSignalFrequenciesForAll.
318 * Alternatively, remove this method call, redeploy the robot application, and power-cycle
319 * the devices on the bus. The user can also override individual status update frequencies
320 * using BaseStatusSignal#SetUpdateFrequency.
321 *
322 * This will wait up to 0.100 seconds (100ms) for each status frame.
323 *
324 * \param devices Devices for which to optimize bus utilization, passed as a vector or initializer list of device addresses.
325 * \returns Status code of the first failed optimize call, or OK if all succeeded
326 */
327 static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll(const std::vector<ParentDevice *> &devices)
328 {
329 return OptimizeBusUtilizationForAll(0_Hz, devices);
330 }
331
332 /**
333 * \brief Optimizes the bus utilization of the provided devices by reducing the update
334 * frequencies of their status signals.
335 *
336 * All status signals that have not been explicitly given an update frequency using
337 * BaseStatusSignal#SetUpdateFrequency will be disabled. Note that if other status
338 * signals in the same status frame have been given an update frequency, the update
339 * frequency will be honored for the entire frame.
340 *
341 * This function only needs to be called once in the robot program for the provided devices.
342 * Additionally, this method does not necessarily need to be called after setting the update
343 * frequencies of other signals.
344 *
345 * To restore the default status update frequencies, call ResetSignalFrequenciesForAll.
346 * Alternatively, remove this method call, redeploy the robot application, and power-cycle
347 * the devices on the bus. The user can also override individual status update frequencies
348 * using BaseStatusSignal#SetUpdateFrequency.
349 *
350 * This will wait up to 0.100 seconds (100ms) for each status frame.
351 *
352 * \param devices Devices for which to optimize bus utilization, passed as an array of device addresses.
353 * \returns Status code of the first failed optimize call, or OK if all succeeded
354 */
355 template <size_t N>
356 static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll(const std::array<ParentDevice *, N> &devices)
357 {
358 return OptimizeBusUtilizationForAll(0_Hz, devices);
359 }
360
361 /**
362 * \brief Optimizes the bus utilization of the provided devices by reducing the update
363 * frequencies of their status signals.
364 *
365 * All status signals that have not been explicitly given an update frequency using
366 * BaseStatusSignal#SetUpdateFrequency will be disabled. Note that if other status
367 * signals in the same status frame have been given an update frequency, the update
368 * frequency will be honored for the entire frame.
369 *
370 * This function only needs to be called once in the robot program for the provided devices.
371 * Additionally, this method does not necessarily need to be called after setting the update
372 * frequencies of other signals.
373 *
374 * To restore the default status update frequencies, call ResetSignalFrequenciesForAll.
375 * Alternatively, remove this method call, redeploy the robot application, and power-cycle
376 * the devices on the bus. The user can also override individual status update frequencies
377 * using BaseStatusSignal#SetUpdateFrequency.
378 *
379 * This will wait up to 0.100 seconds (100ms) for each status frame.
380 *
381 * \param optimizedFreqHz The update frequency to apply to the optimized status signals. A frequency of
382 * 0 Hz (default) will turn off the signals. Otherwise, the minimum supported signal
383 * frequency is 4 Hz.
384 * \param devices Devices for which to optimize bus utilization, passed as a comma-separated list of device references.
385 * \returns Status code of the first failed optimize call, or OK if all succeeded
386 */
387 template <typename... Devices, typename = std::enable_if_t<is_all_device_v<Devices...>>>
389 {
390 return OptimizeBusUtilizationForAll(optimizedFreqHz, std::array<ParentDevice *, sizeof...(Devices)>{(&devices)...});
391 }
392
393 /**
394 * \brief Optimizes the bus utilization of the provided devices by reducing the update
395 * frequencies of their status signals.
396 *
397 * All status signals that have not been explicitly given an update frequency using
398 * BaseStatusSignal#SetUpdateFrequency will be disabled. Note that if other status
399 * signals in the same status frame have been given an update frequency, the update
400 * frequency will be honored for the entire frame.
401 *
402 * This function only needs to be called once in the robot program for the provided devices.
403 * Additionally, this method does not necessarily need to be called after setting the update
404 * frequencies of other signals.
405 *
406 * To restore the default status update frequencies, call ResetSignalFrequenciesForAll.
407 * Alternatively, remove this method call, redeploy the robot application, and power-cycle
408 * the devices on the bus. The user can also override individual status update frequencies
409 * using BaseStatusSignal#SetUpdateFrequency.
410 *
411 * This will wait up to 0.100 seconds (100ms) for each status frame.
412 *
413 * \param optimizedFreqHz The update frequency to apply to the optimized status signals. A frequency of
414 * 0 Hz (default) will turn off the signals. Otherwise, the minimum supported signal
415 * frequency is 4 Hz.
416 * \param devices Devices for which to optimize bus utilization, passed as a vector or initializer list of device addresses.
417 * \returns Status code of the first failed optimize call, or OK if all succeeded
418 */
419 static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll(units::frequency::hertz_t optimizedFreqHz, const std::vector<ParentDevice *> &devices)
420 {
422 for (auto device : devices) {
423 const auto err = device->OptimizeBusUtilization(optimizedFreqHz);
424 if (retval.IsOK()) {
425 retval = err;
426 }
427 }
428 return retval;
429 }
430
431 /**
432 * \brief Optimizes the bus utilization of the provided devices by reducing the update
433 * frequencies of their status signals.
434 *
435 * All status signals that have not been explicitly given an update frequency using
436 * BaseStatusSignal#SetUpdateFrequency will be disabled. Note that if other status
437 * signals in the same status frame have been given an update frequency, the update
438 * frequency will be honored for the entire frame.
439 *
440 * This function only needs to be called once in the robot program for the provided devices.
441 * Additionally, this method does not necessarily need to be called after setting the update
442 * frequencies of other signals.
443 *
444 * To restore the default status update frequencies, call ResetSignalFrequenciesForAll.
445 * Alternatively, remove this method call, redeploy the robot application, and power-cycle
446 * the devices on the bus. The user can also override individual status update frequencies
447 * using BaseStatusSignal#SetUpdateFrequency.
448 *
449 * This will wait up to 0.100 seconds (100ms) for each status frame.
450 *
451 * \param optimizedFreqHz The update frequency to apply to the optimized status signals. A frequency of
452 * 0 Hz (default) will turn off the signals. Otherwise, the minimum supported signal
453 * frequency is 4 Hz.
454 * \param devices Devices for which to optimize bus utilization, passed as an array of device addresses.
455 * \returns Status code of the first failed optimize call, or OK if all succeeded
456 */
457 template <size_t N>
458 static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll(units::frequency::hertz_t optimizedFreqHz, const std::array<ParentDevice *, N> &devices)
459 {
461 for (auto device : devices) {
462 const auto err = device->OptimizeBusUtilization(optimizedFreqHz);
463 if (retval.IsOK()) {
464 retval = err;
465 }
466 }
467 return retval;
468 }
469
470 /**
471 * \brief Resets the update frequencies of all the device's status signals to the defaults.
472 *
473 * This restores the default update frequency of all status signals, including status signals
474 * explicitly given an update frequency using BaseStatusSignal#SetUpdateFrequency and status
475 * signals optimized out using OptimizeBusUtilization.
476 *
477 * \param timeoutSeconds Maximum amount of time to wait for each status frame when performing the action
478 * \returns Status code of the first failed update frequency set call, or OK if all succeeded
479 */
481
482 /**
483 * \brief Resets the update frequencies of all the devices' status signals to the defaults.
484 *
485 * This restores the default update frequency of all status signals, including status signals
486 * explicitly given an update frequency using BaseStatusSignal#SetUpdateFrequency and status
487 * signals optimized out using OptimizeBusUtilizationForAll.
488 *
489 * This will wait up to 0.100 seconds (100ms) for each status frame.
490 *
491 * \param devices Devices for which to restore default update frequencies, passed as a comma-separated list of device references.
492 * \returns Status code of the first failed restore call, or OK if all succeeded
493 */
494 template <typename... Devices, typename = std::enable_if_t<is_all_device_v<Devices...>>>
496 {
497 return ResetSignalFrequenciesForAll(std::array<ParentDevice *, sizeof...(Devices)>{(&devices)...});
498 }
499
500 /**
501 * \brief Resets the update frequencies of all the devices' status signals to the defaults.
502 *
503 * This restores the default update frequency of all status signals, including status signals
504 * explicitly given an update frequency using BaseStatusSignal#SetUpdateFrequency and status
505 * signals optimized out using OptimizeBusUtilizationForAll.
506 *
507 * This will wait up to 0.100 seconds (100ms) for each status frame.
508 *
509 * \param devices Devices for which to restore default update frequencies, passed as a vector or initializer list of device addresses.
510 * \returns Status code of the first failed restore call, or OK if all succeeded
511 */
512 static ctre::phoenix::StatusCode ResetSignalFrequenciesForAll(const std::vector<ParentDevice *> &devices)
513 {
515 for (auto device : devices) {
516 const auto err = device->ResetSignalFrequencies();
517 if (retval.IsOK()) {
518 retval = err;
519 }
520 }
521 return retval;
522 }
523
524 /**
525 * \brief Resets the update frequencies of all the devices' status signals to the defaults.
526 *
527 * This restores the default update frequency of all status signals, including status signals
528 * explicitly given an update frequency using BaseStatusSignal#SetUpdateFrequency and status
529 * signals optimized out using OptimizeBusUtilizationForAll.
530 *
531 * This will wait up to 0.100 seconds (100ms) for each status frame.
532 *
533 * \param devices Devices for which to restore default update frequencies, passed as an array of device addresses.
534 * \returns Status code of the first failed restore call, or OK if all succeeded
535 */
536 template <size_t N>
537 static ctre::phoenix::StatusCode ResetSignalFrequenciesForAll(const std::array<ParentDevice *, N> &devices)
538 {
540 for (auto device : devices) {
541 const auto err = device->ResetSignalFrequencies();
542 if (retval.IsOK()) {
543 retval = err;
544 }
545 }
546 return retval;
547 }
548
549 protected:
551
552 template <typename T>
554 {
555 return LookupCommon<T>(spn, nullptr, std::move(signalName), reportOnConstruction, refresh);
556 }
557
558 template <typename T>
559 StatusSignal<T> &LookupStatusSignal(uint16_t spn, std::function<std::map<uint16_t, std::string>()> mapFiller, std::string signalName, bool reportOnConstruction, bool refresh)
560 {
561 return LookupCommon<T>(spn, std::move(mapFiller), std::move(signalName), reportOnConstruction, refresh);
562 }
563
564 /** Returns a unitless version of the StatusSignal by value. Do not store the result in a reference. */
565 template <typename T, typename U>
567 {
568 return StatusSignal<T>{LookupStatusSignal<U>(spn, std::move(signalName), true, refresh)};
569 }
570 };
571
572}
573}
574}
bool HasUpdated()
Check whether the signal has been updated since the last check.
Definition StatusSignal.hpp:608
const Timestamp & GetTimestamp() const
Get the most accurate timestamp available for this signal.
Definition StatusSignal.hpp:593
Represents a status signal with data of type T, and operations available to retrieve information abou...
Definition StatusSignal.hpp:657
StatusSignal< T > & Refresh(bool ReportOnError=true)
Refreshes the value of this status signal.
Definition StatusSignal.hpp:786
units::time::second_t GetLatency() const
Get the latency of this timestamp compared to now.
Definition Timestamp.hpp:115
Abstract Control Request class that other control requests extend for use.
Definition ControlRequest.hpp:29
Generic Empty Control class used to do nothing.
Definition ControlRequest.hpp:72
Definition DeviceIdentifier.hpp:19
int deviceID
Definition DeviceIdentifier.hpp:23
uint32_t deviceHash
Definition DeviceIdentifier.hpp:24
std::string network
Definition DeviceIdentifier.hpp:21
Parent class for all devices.
Definition ParentDevice.hpp:29
static controls::EmptyControl _emptyControl
Definition ParentDevice.hpp:31
const std::string & GetNetwork() const
Definition ParentDevice.hpp:154
static ctre::phoenix::StatusCode ResetSignalFrequenciesForAll(const std::array< ParentDevice *, N > &devices)
Resets the update frequencies of all the devices' status signals to the defaults.
Definition ParentDevice.hpp:537
static constexpr bool is_all_device_v
Whether all types passed in are subclasses of ParentDevice.
Definition ParentDevice.hpp:47
std::shared_ptr< controls::ControlRequest > GetAppliedControl()
Get the latest applied control.
Definition ParentDevice.hpp:202
StatusSignal< T > LookupDimensionlessStatusSignal(uint16_t spn, std::string signalName, bool refresh)
Returns a unitless version of the StatusSignal by value.
Definition ParentDevice.hpp:566
DeviceIdentifier deviceIdentifier
Definition ParentDevice.hpp:33
StatusSignal< T > & LookupStatusSignal(uint16_t spn, std::string signalName, bool reportOnConstruction, bool refresh)
Definition ParentDevice.hpp:553
ParentDevice(ParentDevice const &)=delete
static ctre::phoenix::StatusCode ResetSignalFrequenciesForAll(const std::vector< ParentDevice * > &devices)
Resets the update frequencies of all the devices' status signals to the defaults.
Definition ParentDevice.hpp:512
bool IsConnected(units::second_t maxLatencySeconds=500_ms)
Returns whether the device is still connected to the robot.
Definition ParentDevice.hpp:234
std::function< bool()> GetResetOccurredChecker() const
Definition ParentDevice.hpp:218
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll(units::frequency::hertz_t optimizedFreqHz, const std::array< ParentDevice *, N > &devices)
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their sta...
Definition ParentDevice.hpp:458
virtual ctre::phoenix::StatusCode SetControlPrivate(const controls::ControlRequest &request)
std::shared_ptr< const controls::ControlRequest > GetAppliedControl() const
Get the latest applied control.
Definition ParentDevice.hpp:185
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll(const std::array< ParentDevice *, N > &devices)
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their sta...
Definition ParentDevice.hpp:356
ctre::phoenix::StatusCode OptimizeBusUtilization(units::frequency::hertz_t optimizedFreqHz=0_Hz, units::time::second_t timeoutSeconds=100_ms)
Optimizes the device's bus utilization by reducing the update frequencies of its status signals.
static ctre::phoenix::StatusCode ResetSignalFrequenciesForAll(Devices &... devices)
Resets the update frequencies of all the devices' status signals to the defaults.
Definition ParentDevice.hpp:495
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll(Devices &... devices)
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their sta...
Definition ParentDevice.hpp:299
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll(units::frequency::hertz_t optimizedFreqHz, Devices &... devices)
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their sta...
Definition ParentDevice.hpp:388
ctre::phoenix::StatusCode ResetSignalFrequencies(units::time::second_t timeoutSeconds=100_ms)
Resets the update frequencies of all the device's status signals to the defaults.
StatusSignal< T > & LookupStatusSignal(uint16_t spn, std::function< std::map< uint16_t, std::string >()> mapFiller, std::string signalName, bool reportOnConstruction, bool refresh)
Definition ParentDevice.hpp:559
int GetDeviceID() const
Definition ParentDevice.hpp:146
ParentDevice(int deviceID, std::string model, std::string canbus)
Definition ParentDevice.hpp:131
uint64_t GetDeviceHash() const
Gets a number unique for this device's hardware type and ID.
Definition ParentDevice.hpp:168
bool HasResetOccurred()
Definition ParentDevice.hpp:210
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll(const std::vector< ParentDevice * > &devices)
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their sta...
Definition ParentDevice.hpp:327
StatusSignal< double > & GetGenericSignal(uint32_t signal, bool refresh=true)
This is a reserved routine for internal testing.
Definition ParentDevice.hpp:246
static ctre::phoenix::StatusCode OptimizeBusUtilizationForAll(units::frequency::hertz_t optimizedFreqHz, const std::vector< ParentDevice * > &devices)
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their sta...
Definition ParentDevice.hpp:419
ParentDevice & operator=(ParentDevice const &)=delete
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:27
static constexpr int OK
No Error.
Definition StatusCodes.h:34
static constexpr int InvalidParamValue
An invalid argument was passed into the function/VI, such as a null pointer.
Definition StatusCodes.h:368
static constexpr int CouldNotRetrieveV6Firmware
Device firmware could not be retrieved.
Definition StatusCodes.h:721
CTREXPORT double GetCurrentTimeSeconds()
Get the current timestamp in seconds.
Definition StatusCodes.h:18
Definition span.hpp:401
Type trait to verify that all types passed in are subclasses of ParentDevice.
Definition ParentDevice.hpp:41