16#if __has_include(<wpi/util/struct/Struct.hpp>)
17#include <wpi/util/struct/Struct.hpp>
18#include <wpi/util/SmallVector.hpp>
20#if __has_include(<wpi/util/protobuf/Protobuf.hpp>)
21#include <wpi/util/protobuf/Protobuf.hpp>
22#include <wpi/util/SmallVector.hpp>
141 return AddSchema(name, type, {(uint8_t
const *)schema.data(), schema.size()});
172 return WriteSchemaValue_Impl(name, schema, type, data, timestamp.value());
175#if __has_include(<wpi/util/struct/Struct.hpp>) || defined(_CTRE_DOCS_)
187 template <
typename T,
typename... I>
188 requires wpi::util::StructSerializable<T, I...>
191 using S = wpi::util::Struct<T, I...>;
193 auto const typeName = S::GetTypeName(info...);
196 if constexpr (wpi::util::HasNestedStruct<T, I...>) {
197 S::ForEachNested([](std::string_view typeName,
auto schema) {
198 if (typeName.starts_with(
"struct:")) {
199 typeName.remove_prefix(7);
209 if constexpr (
sizeof...(I) == 0) {
210 if constexpr (wpi::util::is_constexpr([] { S::GetSize(); })) {
211 std::array<uint8_t, S::GetSize()> data;
212 S::Pack(data, value);
217 wpi::util::SmallVector<uint8_t, 128> buf;
218 buf.resize_for_overwrite(S::GetSize(info...));
219 S::Pack(buf, value, info...);
234 template <
typename T,
typename... I>
235 requires wpi::util::StructSerializable<T, I...>
238 using S = wpi::util::Struct<T, I...>;
240 auto const typeName = wpi::util::MakeStructArrayTypeName<T, std::dynamic_extent>(info...);
243 wpi::util::ForEachStructSchema<T>([](std::string_view typeName,
auto schema) {
244 if (typeName.starts_with(
"struct:")) {
245 typeName.remove_prefix(7);
254 auto const size = S::GetSize(info...);
255 wpi::util::SmallVector<uint8_t, 256> buf;
256 buf.resize_for_overwrite(size * values.size());
258 uint8_t *out = buf.data();
259 for (
auto &&val : values) {
261 std::span<uint8_t>{out, size},
262 std::forward<decltype(val)>(val), info...
270#if __has_include(<wpi/util/protobuf/Protobuf.hpp>) || defined(_CTRE_DOCS_)
280 template <wpi::util::ProtobufSerializable T>
283 std::string_view
const typeName = wpi::util::Protobuf<std::remove_cvref_t<T>>::MessageStruct::msg_descriptor()->proto_name;
285 wpi::util::ProtobufMessage<T> proto;
287 proto.ForEachProtobufDescriptor(
288 [](std::string_view typeName) {
289 if (typeName.starts_with(
"proto:")) {
290 typeName.remove_prefix(6);
294 [](std::string_view typeName,
auto schema) {
295 if (typeName.starts_with(
"proto:")) {
296 typeName.remove_prefix(6);
304 wpi::util::SmallVector<uint8_t, 128> buf;
305 proto.Pack(buf, value);
320 return WriteRaw_Impl(name, data, timestamp.value());
332 return WriteBoolean_Impl(name, value, timestamp.value());
345 return WriteInteger_Impl(name, value, units, timestamp.value());
358 return WriteFloat_Impl(name, value, units, timestamp.value());
371 return WriteDouble_Impl(name, value, units, timestamp.value());
383 return WriteString_Impl(name, value, timestamp.value());
395 template <
typename U>
396 requires wpi::units::traits::is_unit_t_v<U>
399 return WriteDouble(name, value.value(), wpi::units::abbreviation(value), timestamp);
412 return WriteBooleanArray_Impl(name, values, timestamp.value());
424 return WriteBooleanArray_Impl(name, values, timestamp.value());
438 return WriteIntegerArray_Impl(name, values, units, timestamp.value());
452 return WriteFloatArray_Impl(name, values, units, timestamp.value());
466 return WriteDoubleArray_Impl(name, values, units, timestamp.value());
479 return WriteStringArray_Impl(name, values, timestamp.value());
491 return WriteStringArray_Impl(name, values, timestamp.value());
495 static ctre::phoenix::StatusCode WriteRaw_Impl(std::string_view name, std::span<uint8_t const> data,
double timestampSeconds);
497 static ctre::phoenix::StatusCode WriteInteger_Impl(std::string_view name, int64_t value, std::string_view units,
double timestampSeconds);
498 static ctre::phoenix::StatusCode WriteFloat_Impl(std::string_view name,
float value, std::string_view units,
double timestampSeconds);
499 static ctre::phoenix::StatusCode WriteDouble_Impl(std::string_view name,
double value, std::string_view units,
double timestampSeconds);
500 static ctre::phoenix::StatusCode WriteString_Impl(std::string_view name, std::string_view value,
double timestampSeconds);
502 static ctre::phoenix::StatusCode WriteBooleanArray_Impl(std::string_view name, std::span<bool const> values,
double timestampSeconds)
504 static_assert(
sizeof(bool) ==
sizeof(uint8_t),
"bool is not uint8_t");
505 return WriteBooleanArray_Impl(name, std::span{(uint8_t
const *)values.data(), values.size()}, timestampSeconds);
507 static ctre::phoenix::StatusCode WriteBooleanArray_Impl(std::string_view name, std::span<uint8_t const> values,
double timestampSeconds);
508 static ctre::phoenix::StatusCode WriteIntegerArray_Impl(std::string_view name, std::span<int64_t const> values, std::string_view units,
double timestampSeconds);
509 static ctre::phoenix::StatusCode WriteFloatArray_Impl(std::string_view name, std::span<float const> values, std::string_view units,
double timestampSeconds);
510 static ctre::phoenix::StatusCode WriteDoubleArray_Impl(std::string_view name, std::span<double const> values, std::string_view units,
double timestampSeconds);
511 static ctre::phoenix::StatusCode WriteStringArray_Impl(std::string_view name, std::span<std::string_view const> values,
double timestampSeconds);
512 static ctre::phoenix::StatusCode WriteStringArray_Impl(std::string_view name, std::span<std::string const> values,
double timestampSeconds);
Static class for controlling the Phoenix 6 signal logger.
Definition SignalLogger.hpp:42
static ctre::phoenix::StatusCode WriteStructArray(std::string_view name, std::span< T const > values, I const &... info, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the array of WPILib Structs to the log file.
Definition SignalLogger.hpp:236
static ctre::phoenix::StatusCode WriteStruct(std::string_view name, T const &value, I const &... info, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the WPILib Struct to the log file.
Definition SignalLogger.hpp:189
static bool HasSchema(std::string_view name, HootSchemaType type)
Checks if the schema has already been added to the log files.
static ctre::phoenix::StatusCode WriteSchemaValue(std::string_view name, std::string_view schema, HootSchemaType type, std::span< uint8_t const > data, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the schema-serialized bytes to the log file.
Definition SignalLogger.hpp:170
static ctre::phoenix::StatusCode WriteStringArray(std::string_view name, std::span< std::string const > values, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the array of strings to the log file.
Definition SignalLogger.hpp:489
static ctre::phoenix::StatusCode WriteStringArray(std::string_view name, std::span< std::string_view const > values, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the array of strings to the log file.
Definition SignalLogger.hpp:477
static ctre::phoenix::StatusCode WriteFloat(std::string_view name, float value, std::string_view units="", wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the float to the log file.
Definition SignalLogger.hpp:356
static ctre::phoenix::StatusCode SetPath(const char *path)
Sets the destination for logging, restarting logger if the path changed.
static ctre::phoenix::StatusCode WriteFloatArray(std::string_view name, std::span< float const > values, std::string_view units="", wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the array of floats to the log file.
Definition SignalLogger.hpp:450
static ctre::phoenix::StatusCode AddSchema(std::string_view name, HootSchemaType type, std::string_view schema)
Adds the schema to the log file.
Definition SignalLogger.hpp:139
static ctre::phoenix::StatusCode WriteRaw(std::string_view name, std::span< uint8_t const > data, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the raw data bytes to the log file.
Definition SignalLogger.hpp:318
static ctre::phoenix::StatusCode WriteDouble(std::string_view name, double value, std::string_view units="", wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the double to the log file.
Definition SignalLogger.hpp:369
static ctre::phoenix::StatusCode WriteBooleanArray(std::string_view name, std::span< uint8_t const > values, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the array of booleans to the log file.
Definition SignalLogger.hpp:422
static ctre::phoenix::StatusCode WriteBooleanArray(std::string_view name, std::span< bool const > values, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the array of booleans to the log file.
Definition SignalLogger.hpp:410
static ctre::phoenix::StatusCode WriteBoolean(std::string_view name, bool value, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the boolean to the log file.
Definition SignalLogger.hpp:330
static ctre::phoenix::StatusCode WriteProtobuf(std::string_view name, T const &value, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the protobuf to the log file.
Definition SignalLogger.hpp:281
static ctre::phoenix::StatusCode Stop()
Stops logging status signals.
static ctre::phoenix::StatusCode WriteDoubleArray(std::string_view name, std::span< double const > values, std::string_view units="", wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the array of doubles to the log file.
Definition SignalLogger.hpp:464
static ctre::phoenix::StatusCode WriteString(std::string_view name, std::string_view value, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the string to the log file.
Definition SignalLogger.hpp:381
static ctre::phoenix::StatusCode WriteIntegerArray(std::string_view name, std::span< int64_t const > values, std::string_view units="", wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the array of integers to the log file.
Definition SignalLogger.hpp:436
static ctre::phoenix::StatusCode WriteValue(std::string_view name, U value, wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the unit value to the log file.
Definition SignalLogger.hpp:397
static ctre::phoenix::StatusCode EnableAutoLogging(bool enable)
Enables or disables auto logging.
static ctre::phoenix::StatusCode Start()
Starts logging status signals.
static ctre::phoenix::StatusCode AddSchema(std::string_view name, HootSchemaType type, std::span< uint8_t const > schema)
Adds the schema to the log file.
static ctre::phoenix::StatusCode WriteInteger(std::string_view name, int64_t value, std::string_view units="", wpi::units::second_t timestamp=utils::GetCurrentTime())
Writes the integer to the log file.
Definition SignalLogger.hpp:343
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
wpi::units::second_t GetCurrentTime()
Get the current timestamp.
Definition Utils.hpp:27
Definition ExternalFeedbackConfigs.hpp:16
HootSchemaType
Supported schema types for a hoot user signal.
Definition HootSchemaType.hpp:15
@ Struct
Serialize using the WPILib Struct format.
Definition HootSchemaType.hpp:19
@ Protobuf
Serialize using the Protobuf format.
Definition HootSchemaType.hpp:23
Definition motor_constants.h:14