CTRE Phoenix 6 C++ 26.70.0-alpha-2
Loading...
Searching...
No Matches
HootTelemetryBackend.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
9#include <wpi/telemetry/TelemetryBackend.hpp>
10#include <map>
11#include <mutex>
12
13namespace ctre {
14namespace phoenix6 {
15
16 /**
17 * \brief A telemetry backend implementation that saves information to a CTRE hoot
18 * file on disk using the Phoenix 6 SignalLogger.
19 */
20 class HootTelemetryBackend final : public wpi::telemetry::TelemetryBackend {
21 class Entry;
22
23 std::string prefix;
24
25 std::mutex entriesLock;
26 std::map<std::string, std::shared_ptr<Entry>, std::less<>> entries;
27
28 public:
29 /**
30 * \brief Creates a new hoot telemetry backend. This immediately starts
31 * the SignalLogger and automatically stops it once all instances are
32 * destroyed.
33 *
34 * This will use the default path documented in SignalLogger#SetPath.
35 *
36 * \param prefix Prefix to prepend to all log entry names; defaults empty
37 */
38 HootTelemetryBackend(std::string prefix = "");
39
40 /**
41 * \brief Creates a new hoot telemetry backend with the target file path.
42 * This immediately starts the SignalLogger and automatically stops it
43 * once all instances are destroyed.
44 *
45 * \param prefix Prefix to prepend to all log entry names; defaults empty
46 * \param path Folder path for the log files; path must exist
47 */
48 HootTelemetryBackend(std::string prefix, char const *path);
49
51
52 /**
53 * \brief Create an entry for the given path.
54 *
55 * \param path full name
56 * \returns telemetry entry
57 */
58 std::shared_ptr<wpi::telemetry::TelemetryEntry> GetEntry(std::string_view path) override;
59 /**
60 * \brief Removes an entry for the given path.
61 *
62 * \param path normalized full name
63 */
64 void RemoveEntry(std::string_view path) override;
65
66 /**
67 * \brief Returns whether there is a data schema already registered with the given
68 * name. This does NOT perform a check as to whether the schema has already
69 * been published by another node on the network.
70 *
71 * \param schemaName Name (the string passed as the data type for topics using
72 * this schema)
73 * \returns True if schema already registered
74 */
75 bool HasSchema(std::string_view schemaName) const override;
76 /**
77 * \brief Registers a data schema. Data schemas provide information for how a
78 * certain data type string can be decoded. The type string of a data schema
79 * indicates the type of the schema itself (e.g. "protobuf" for protobuf
80 * schemas, "struct" for struct schemas, etc). Duplicate calls to this function
81 * with the same name are silently ignored.
82 *
83 * \param schemaName Name (the string passed as the data type for topics using
84 * this schema)
85 * \param type Type of schema (e.g. "protobuf", "struct", etc)
86 * \param schema Schema data
87 */
88 void AddSchema(std::string_view schemaName, std::string_view type, std::span<uint8_t const> schema) override;
89 /**
90 * \brief Registers a data schema. Data schemas provide information for how a
91 * certain data type string can be decoded. The type string of a data schema
92 * indicates the type of the schema itself (e.g. "protobuf" for protobuf
93 * schemas, "struct" for struct schemas, etc). Duplicate calls to this function
94 * with the same name are silently ignored.
95 *
96 * \param schemaName Name (the string passed as the data type for topics using
97 * this schema)
98 * \param type Type of schema (e.g. "protobuf", "struct", etc)
99 * \param schema Schema data
100 */
101 void AddSchema(std::string_view schemaName, std::string_view type, std::string_view schema) override;
102 };
103
104}
105}
void AddSchema(std::string_view schemaName, std::string_view type, std::string_view schema) override
Registers a data schema.
HootTelemetryBackend(std::string prefix="")
Creates a new hoot telemetry backend.
void RemoveEntry(std::string_view path) override
Removes an entry for the given path.
std::shared_ptr< wpi::telemetry::TelemetryEntry > GetEntry(std::string_view path) override
Create an entry for the given path.
HootTelemetryBackend(std::string prefix, char const *path)
Creates a new hoot telemetry backend with the target file path.
bool HasSchema(std::string_view schemaName) const override
Returns whether there is a data schema already registered with the given name.
void AddSchema(std::string_view schemaName, std::string_view type, std::span< uint8_t const > schema) override
Registers a data schema.
Definition ExternalFeedbackConfigs.hpp:16
Definition motor_constants.h:14