CTRE Phoenix 6 C++ 26.70.0-alpha-2
Loading...
Searching...
No Matches
SignalMeasurement.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#include <concepts>
11#include <ostream>
12#include <sstream>
13#include <string>
14#include <wpi/units/time.hpp>
15
16namespace ctre {
17namespace phoenix6 {
18
19 /**
20 * \brief Information from a single measurement of a status signal.
21 *
22 * \tparam T Type of the signal
23 */
24 template <typename T>
26 /**
27 * \brief The name of the signal
28 */
29 std::string_view name;
30 /**
31 * \brief The value of the signal
32 */
34 /**
35 * \brief Timestamp of when the data point was taken
36 */
37 wpi::units::second_t timestamp;
38 /**
39 * \brief The units of the signal measurement
40 */
41 std::string units;
42 /**
43 * \brief Status code response of getting the data
44 */
46
47 friend std::ostream &operator<<(std::ostream &os, SignalMeasurement<T> const &data)
48 {
49 os << "SignalMeasurement: " << data.name << '\n';
50 os << " Value: ";
51 if constexpr(wpi::units::traits::is_unit_t_v<T>) {
52 os << data.value.value() << ' ' << data.units << '\n';
53 } else {
54 os << data.value << ' ' << data.units << '\n';
55 }
56 os << " Timestamp: " << data.timestamp.value() << " s\n";
57 os << " Status: " << data.status.GetName();
58 return os;
59 }
60 std::string ToString() const
61 {
62 std::stringstream ss;
63 ss << *this;
64 return ss.str();
65 }
66
67 bool operator==(SignalMeasurement const &other) const
68 requires std::equality_comparable<T> = default;
69 };
70
71}
72}
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
constexpr const char * GetName() const
Gets the name of this StatusCode.
Definition StatusCodes.h:867
Definition ExternalFeedbackConfigs.hpp:16
Definition motor_constants.h:14
Information from a single measurement of a status signal.
Definition SignalMeasurement.hpp:25
T value
The value of the signal.
Definition SignalMeasurement.hpp:33
bool operator==(SignalMeasurement const &other) const =default
wpi::units::second_t timestamp
Timestamp of when the data point was taken.
Definition SignalMeasurement.hpp:37
std::string units
The units of the signal measurement.
Definition SignalMeasurement.hpp:41
std::string ToString() const
Definition SignalMeasurement.hpp:60
friend std::ostream & operator<<(std::ostream &os, SignalMeasurement< T > const &data)
Definition SignalMeasurement.hpp:47
ctre::phoenix::StatusCode status
Status code response of getting the data.
Definition SignalMeasurement.hpp:45
std::string_view name
The name of the signal.
Definition SignalMeasurement.hpp:29