12#include <units/time.h>
16#if __has_include("wpi/struct/Struct.h")
17#include "wpi/struct/Struct.h"
19#if __has_include("wpi/protobuf/Protobuf.h")
20#include "wpi/protobuf/Protobuf.h"
111 auto retval =
Stop();
150 return WaitForPlayingImpl(timeout.value());
181 return StepTimingImpl(stepTimeSeconds.value());
196 return GetSchemaValueImpl(name, type).ToSignalMeasurement();
199#if __has_include("wpi/struct/Struct.h") || defined(_CTRE_DOCS_)
207 template <
typename T,
typename... I>
208 requires wpi::StructSerializable<T, I...>
213 std::optional<T> value;
214 if (rawSig.status.IsOK()) {
215 if (rawSig.value.size() == wpi::Struct<T>::GetSize(info...)) {
216 value = wpi::Struct<T>::Unpack(rawSig.value, info...);
218 value = std::nullopt;
222 value = std::nullopt;
229 std::move(rawSig.units),
240 template <
typename T,
typename... I>
241 requires wpi::StructSerializable<T, I...>
246 std::optional<std::vector<T>> value;
247 if (rawSig.status.IsOK()) {
248 std::span<uint8_t const> data{rawSig.value};
249 auto const size = wpi::Struct<T>::GetSize(info...);
250 size_t const arr_size = data.size() / size;
252 if (arr_size * size == data.size()) {
254 arr.reserve(arr_size);
255 for (
size_t i = 0; i < arr_size; ++i) {
256 arr.emplace_back(wpi::UnpackStruct<T>(data, info...));
257 data = data.subspan(size);
259 value = std::move(arr);
261 value = std::nullopt;
265 value = std::nullopt;
272 std::move(rawSig.units),
278#if __has_include("wpi/protobuf/Protobuf.h") || defined(_CTRE_DOCS_)
285 template <wpi::ProtobufSerializable T>
292 ? wpi::ProtobufMessage<T>{}.Unpack(rawSig.value)
295 std::move(rawSig.units),
309 return GetRawImpl(name).ToSignalMeasurement();
319 return GetBooleanImpl(name).ToSignalMeasurement();
329 return GetIntegerImpl(name).ToSignalMeasurement();
339 return GetFloatImpl(name).ToSignalMeasurement();
349 return GetDoubleImpl(name).ToSignalMeasurement();
358 template <
typename U>
359 requires units::traits::is_unit_t_v<U>
367 std::move(doubleSig.
units),
380 return GetStringImpl(name).ToSignalMeasurement();
390 return GetBooleanArrayImpl(name).ToSignalMeasurement();
400 return GetIntegerArrayImpl(name).ToSignalMeasurement();
410 return GetFloatArrayImpl(name).ToSignalMeasurement();
420 return GetDoubleArrayImpl(name).ToSignalMeasurement();
430 return GetStringArrayImpl(name).ToSignalMeasurement();
434 static bool WaitForPlayingImpl(
double timeoutSeconds);
437 template <
typename T>
438 struct UnitlessSignalData {
439 std::string_view name;
457 static UnitlessSignalData<std::vector<uint8_t>> GetSchemaValueImpl(std::string_view name,
HootSchemaType type);
458 static UnitlessSignalData<std::vector<uint8_t>> GetRawImpl(std::string_view name);
459 static UnitlessSignalData<bool> GetBooleanImpl(std::string_view name);
460 static UnitlessSignalData<int64_t> GetIntegerImpl(std::string_view name);
461 static UnitlessSignalData<float> GetFloatImpl(std::string_view name);
462 static UnitlessSignalData<double> GetDoubleImpl(std::string_view name);
463 static UnitlessSignalData<std::string> GetStringImpl(std::string_view name);
464 static UnitlessSignalData<std::vector<uint8_t>> GetBooleanArrayImpl(std::string_view name);
465 static UnitlessSignalData<std::vector<int64_t>> GetIntegerArrayImpl(std::string_view name);
466 static UnitlessSignalData<std::vector<float>> GetFloatArrayImpl(std::string_view name);
467 static UnitlessSignalData<std::vector<double>> GetDoubleArrayImpl(std::string_view name);
468 static UnitlessSignalData<std::vector<std::string>> GetStringArrayImpl(std::string_view name);
Static class for controlling Phoenix 6 hoot log replay.
Definition HootReplay.hpp:49
static ctre::phoenix::StatusCode Play()
Starts or resumes the hoot log replay.
static SignalMeasurement< std::vector< int64_t > > GetIntegerArray(std::string_view name)
Get an integer array user signal.
Definition HootReplay.hpp:398
static SignalMeasurement< std::vector< float > > GetFloatArray(std::string_view name)
Get a float array user signal.
Definition HootReplay.hpp:408
static ctre::phoenix::StatusCode Stop()
Stops the hoot log replay.
static SignalMeasurement< std::vector< double > > GetDoubleArray(std::string_view name)
Get a double array user signal.
Definition HootReplay.hpp:418
static bool IsFileLoaded()
Gets whether a valid hoot log file is currently loaded.
static void CloseFile()
Ends the hoot log replay.
static void SetSpeed(double speed)
Sets the speed of the hoot log replay.
static bool WaitForPlaying(units::second_t timeout)
Waits until hoot log replay is actively playing.
Definition HootReplay.hpp:148
static SignalMeasurement< int64_t > GetInteger(std::string_view name)
Gets an integer user signal.
Definition HootReplay.hpp:327
static ctre::phoenix::StatusCode StepTiming(units::time::second_t stepTimeSeconds)
Advances the hoot log replay time by the given value.
Definition HootReplay.hpp:179
static SignalMeasurement< std::optional< std::vector< T > > > GetStructArray(std::string_view name, I const &... info)
Gets a WPILib Struct array user signal.
Definition HootReplay.hpp:242
static bool IsPlaying()
Gets whether hoot log replay is actively playing.
Definition HootReplay.hpp:127
static SignalMeasurement< std::optional< T > > GetStruct(std::string_view name, I const &... info)
Gets a WPILib Struct user signal.
Definition HootReplay.hpp:209
static ctre::phoenix::StatusCode LoadFile(char const *filepath)
Loads the given file and starts signal log replay.
static SignalMeasurement< std::vector< uint8_t > > GetSchemaValue(std::string_view name, HootSchemaType type)
Gets a schema-serialized user signal.
Definition HootReplay.hpp:194
static SignalMeasurement< U > GetValue(std::string_view name)
Gets a unit value user signal.
Definition HootReplay.hpp:360
static SignalMeasurement< std::vector< uint8_t > > GetRaw(std::string_view name)
Gets a raw-bytes user signal.
Definition HootReplay.hpp:307
static ctre::phoenix::StatusCode Restart()
Restarts the hoot log replay from the start of the log.
Definition HootReplay.hpp:109
static SignalMeasurement< std::string > GetString(std::string_view name)
Gets a string user signal.
Definition HootReplay.hpp:378
static SignalMeasurement< std::optional< T > > GetProtobuf(std::string_view name)
Gets a Protobuf user signal.
Definition HootReplay.hpp:286
static bool IsFinished()
Gets whether hoot log replay has reached the end of the log.
static SignalMeasurement< bool > GetBoolean(std::string_view name)
Gets a boolean user signal.
Definition HootReplay.hpp:317
static SignalMeasurement< std::vector< uint8_t > > GetBooleanArray(std::string_view name)
Get a boolean array user signal.
Definition HootReplay.hpp:388
static SignalMeasurement< double > GetDouble(std::string_view name)
Gets a double user signal.
Definition HootReplay.hpp:347
static SignalMeasurement< float > GetFloat(std::string_view name)
Gets a float user signal.
Definition HootReplay.hpp:337
static SignalMeasurement< std::vector< std::string > > GetStringArray(std::string_view name)
Get a string array user signal.
Definition HootReplay.hpp:428
static ctre::phoenix::StatusCode Pause()
Pauses the hoot log replay.
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
static constexpr int InvalidParamValue
An invalid argument was passed into the function/VI, such as a null pointer.
Definition StatusCodes.h:369
HootSchemaType
Supported schema types for a hoot user signal.
Definition HootSchemaType.hpp:15
@ Struct
Serialize using the WPILib Struct format.
@ Protobuf
Serialize using the Protobuf format.
Definition motor_constants.h:14
Information from a single measurement of a status signal.
Definition SignalMeasurement.hpp:20
T value
The value of the signal.
Definition SignalMeasurement.hpp:28
std::string units
The units of the signal measurement.
Definition SignalMeasurement.hpp:36
ctre::phoenix::StatusCode status
Status code response of getting the data.
Definition SignalMeasurement.hpp:40
units::time::second_t timestamp
Timestamp of when the data point was taken.
Definition SignalMeasurement.hpp:32
std::string_view name
The name of the signal.
Definition SignalMeasurement.hpp:24