12#include <wpi/units/time.hpp>
16#if __has_include(<wpi/util/struct/Struct.hpp>)
17#include <wpi/util/struct/Struct.hpp>
19#if __has_include(<wpi/util/protobuf/Protobuf.hpp>)
20#include <wpi/util/protobuf/Protobuf.hpp>
127 auto retval =
Stop();
166 return WaitForPlayingImpl(timeout.value());
197 return StepTimingImpl(stepTimeSeconds.value());
212 return GetSchemaValueImpl(name, type).ToSignalMeasurement();
215#if __has_include(<wpi/util/struct/Struct.hpp>) || defined(_CTRE_DOCS_)
225 template <
typename T,
typename... I>
226 requires wpi::util::StructSerializable<T, I...>
231 std::optional<T> value;
232 if (rawSig.status.IsOK()) {
233 if (rawSig.value.size() == wpi::util::Struct<T>::GetSize(info...)) {
234 value = wpi::util::Struct<T>::Unpack(rawSig.value, info...);
236 value = std::nullopt;
240 value = std::nullopt;
247 std::move(rawSig.units),
260 template <
typename T,
typename... I>
261 requires wpi::util::StructSerializable<T, I...>
266 std::optional<std::vector<T>> value;
267 if (rawSig.status.IsOK()) {
268 std::span<uint8_t const> data{rawSig.value};
269 auto const size = wpi::util::Struct<T>::GetSize(info...);
270 size_t const arr_size = data.size() / size;
272 if (arr_size * size == data.size()) {
274 arr.reserve(arr_size);
275 for (
size_t i = 0; i < arr_size; ++i) {
276 arr.emplace_back(wpi::util::UnpackStruct<T>(data, info...));
277 data = data.subspan(size);
279 value = std::move(arr);
281 value = std::nullopt;
285 value = std::nullopt;
292 std::move(rawSig.units),
298#if __has_include(<wpi/util/protobuf/Protobuf.hpp>) || defined(_CTRE_DOCS_)
306 template <wpi::util::ProtobufSerializable T>
313 ? wpi::util::ProtobufMessage<T>{}.Unpack(rawSig.value)
316 std::move(rawSig.units),
330 return GetRawImpl(name).ToSignalMeasurement();
340 return GetBooleanImpl(name).ToSignalMeasurement();
350 return GetIntegerImpl(name).ToSignalMeasurement();
360 return GetFloatImpl(name).ToSignalMeasurement();
370 return GetDoubleImpl(name).ToSignalMeasurement();
380 template <
typename U>
381 requires wpi::units::traits::is_unit_t_v<U>
389 std::move(doubleSig.
units),
402 return GetStringImpl(name).ToSignalMeasurement();
412 return GetBooleanArrayImpl(name).ToSignalMeasurement();
422 return GetIntegerArrayImpl(name).ToSignalMeasurement();
432 return GetFloatArrayImpl(name).ToSignalMeasurement();
442 return GetDoubleArrayImpl(name).ToSignalMeasurement();
452 return GetStringArrayImpl(name).ToSignalMeasurement();
456 static bool WaitForPlayingImpl(
double timeoutSeconds);
459 template <
typename T>
460 struct UnitlessSignalData {
461 std::string_view name;
479 static UnitlessSignalData<std::vector<uint8_t>> GetSchemaValueImpl(std::string_view name,
HootSchemaType type);
480 static UnitlessSignalData<std::vector<uint8_t>> GetRawImpl(std::string_view name);
481 static UnitlessSignalData<bool> GetBooleanImpl(std::string_view name);
482 static UnitlessSignalData<int64_t> GetIntegerImpl(std::string_view name);
483 static UnitlessSignalData<float> GetFloatImpl(std::string_view name);
484 static UnitlessSignalData<double> GetDoubleImpl(std::string_view name);
485 static UnitlessSignalData<std::string> GetStringImpl(std::string_view name);
486 static UnitlessSignalData<std::vector<uint8_t>> GetBooleanArrayImpl(std::string_view name);
487 static UnitlessSignalData<std::vector<int64_t>> GetIntegerArrayImpl(std::string_view name);
488 static UnitlessSignalData<std::vector<float>> GetFloatArrayImpl(std::string_view name);
489 static UnitlessSignalData<std::vector<double>> GetDoubleArrayImpl(std::string_view name);
490 static UnitlessSignalData<std::vector<std::string>> GetStringArrayImpl(std::string_view name);
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:420
static SignalMeasurement< std::vector< float > > GetFloatArray(std::string_view name)
Get a float array user signal.
Definition HootReplay.hpp:430
static ctre::phoenix::StatusCode Stop()
Stops the hoot log replay.
static SignalMeasurement< std::optional< T > > GetStruct(std::string_view name, I const &... info)
Gets a WPILib Struct user signal.
Definition HootReplay.hpp:227
static SignalMeasurement< std::vector< double > > GetDoubleArray(std::string_view name)
Get a double array user signal.
Definition HootReplay.hpp:440
void Close()
Ends the hoot log replay.
static bool IsFileLoaded()
Gets whether a valid hoot log file is currently loaded.
static void SetSpeed(double speed)
Sets the speed of the hoot log replay.
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:262
static SignalMeasurement< int64_t > GetInteger(std::string_view name)
Gets an integer user signal.
Definition HootReplay.hpp:348
static bool IsPlaying()
Gets whether hoot log replay is actively playing.
Definition HootReplay.hpp:143
HootReplay(HootReplay &&other)
static SignalMeasurement< U > GetValue(std::string_view name)
Gets a unit value user signal.
Definition HootReplay.hpp:382
~HootReplay()
Definition HootReplay.hpp:77
static SignalMeasurement< std::vector< uint8_t > > GetSchemaValue(std::string_view name, HootSchemaType type)
Gets a schema-serialized user signal.
Definition HootReplay.hpp:210
static SignalMeasurement< std::vector< uint8_t > > GetRaw(std::string_view name)
Gets a raw-bytes user signal.
Definition HootReplay.hpp:328
static ctre::phoenix::StatusCode Restart()
Restarts the hoot log replay from the start of the log.
Definition HootReplay.hpp:125
static SignalMeasurement< std::string > GetString(std::string_view name)
Gets a string user signal.
Definition HootReplay.hpp:400
static ctre::phoenix::StatusCode StepTiming(wpi::units::second_t stepTimeSeconds)
Advances the hoot log replay time by the given value.
Definition HootReplay.hpp:195
HootReplay & operator=(HootReplay &&other)
static SignalMeasurement< std::optional< T > > GetProtobuf(std::string_view name)
Gets a Protobuf user signal.
Definition HootReplay.hpp:307
static bool IsFinished()
Gets whether hoot log replay has reached the end of the log.
HootReplay(char const *filepath)
Loads the given file and starts signal log replay.
static SignalMeasurement< bool > GetBoolean(std::string_view name)
Gets a boolean user signal.
Definition HootReplay.hpp:338
static SignalMeasurement< std::vector< uint8_t > > GetBooleanArray(std::string_view name)
Get a boolean array user signal.
Definition HootReplay.hpp:410
static SignalMeasurement< double > GetDouble(std::string_view name)
Gets a double user signal.
Definition HootReplay.hpp:368
static bool WaitForPlaying(wpi::units::second_t timeout)
Waits until hoot log replay is actively playing.
Definition HootReplay.hpp:164
ctre::phoenix::StatusCode GetStatus() const
Gets the status from opening and reading the file for replay.
Definition HootReplay.hpp:90
static SignalMeasurement< float > GetFloat(std::string_view name)
Gets a float user signal.
Definition HootReplay.hpp:358
static SignalMeasurement< std::vector< std::string > > GetStringArray(std::string_view name)
Get a string array user signal.
Definition HootReplay.hpp:450
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:370
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
Information from a single measurement of a status signal.
Definition SignalMeasurement.hpp:25
T value
The value of the signal.
Definition SignalMeasurement.hpp:33
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
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