ReduxLib C++ 2025.0.0-beta2
Loading...
Searching...
No Matches
CanandmagStruct.h
1// Copyright (c) Redux Robotics and other contributors.
2// This is open source and can be modified and shared under the 3-clause BSD license.
3
4#pragma once
5#include "redux/sensors/canandmag/CanandmagFaults.h"
6#include "redux/sensors/canandmag/CanandmagStatus.h"
7#include "wpi/struct/Struct.h"
8
9namespace wpi {
10
11/** WPILib struct template for CanandmagFaults */
12template <>
14 /** @return Type string name */
15 static constexpr std::string_view GetTypeName() {
16 return "CanandmagFaults";
17 }
18 /** @return size of serialized payload in bytes */
19 static constexpr size_t GetSize() { return 1; }
20
21 /** @return wpistruct schema */
22 static constexpr std::string_view GetSchema() {
23 return (
24 "bool power_cycle:1;"
25 "bool can_id_conflict:1;"
26 "bool can_general_error:1;"
27 "bool out_of_temperature_range:1;"
28 "bool hardware_fault:1;"
29 "bool magnet_out_of_range:1;"
30 "bool under_volt:1;"
31 "bool reserved:1;"
32 );
33 }
34
35 /**
36 * @param data to unpack to object
37 * @return CanandmagFaults
38 */
39 static ::redux::sensors::canandmag::CanandmagFaults Unpack(std::span<const uint8_t> data);
40 /**
41 * @param data to pack object into
42 * @param value object reference
43 */
44 static void Pack(std::span<uint8_t> data,
45 const ::redux::sensors::canandmag::CanandmagFaults& value);
46};
47
48/** WPILib struct template for CanandmagStatus */
49template <>
51 /** @return Type string name */
52 static constexpr std::string_view GetTypeName() {
53 return "CanandmagStatus";
54 }
55 /** @return size of serialized payload in bytes */
56 static constexpr size_t GetSize() { return 10; }
57 /** @return wpistruct schema */
58 static constexpr std::string_view GetSchema() {
59 return (
60 "CanandmagFaults active_faults;"
61 "CanandmagFaults sticky_faults;"
62 "double temperature;"
63 );
64 }
65
66 /**
67 * @param data to unpack to object
68 * @return CanandmagStatus
69 */
70 static ::redux::sensors::canandmag::CanandmagStatus Unpack(std::span<const uint8_t> data);
71 /**
72 * @param data to pack object into
73 * @param value object reference
74 */
75 static void Pack(std::span<uint8_t> data,
76 const ::redux::sensors::canandmag::CanandmagStatus& value);
77 /**
78 * @param fn to run
79 */
80 static void ForEachNested(
81 std::invocable<std::string_view, std::string_view> auto fn) {
82 wpi::ForEachStructSchema<::redux::sensors::canandmag::CanandmagFaults>(fn);
83 }
84};
85}
86
87static_assert(wpi::StructSerializable<::redux::sensors::canandmag::CanandmagStatus>);
88static_assert(wpi::StructSerializable<::redux::sensors::canandmag::CanandmagFaults>);
89static_assert(wpi::HasNestedStruct<::redux::sensors::canandmag::CanandmagStatus>);
Definition: CanandmagFaults.h:13
Definition: CanandmagStatus.h:13
static constexpr std::string_view GetTypeName()
Definition: CanandmagStruct.h:15
static constexpr size_t GetSize()
Definition: CanandmagStruct.h:19
static constexpr std::string_view GetSchema()
Definition: CanandmagStruct.h:22
static void Pack(std::span< uint8_t > data, const ::redux::sensors::canandmag::CanandmagFaults &value)
::redux::sensors::canandmag::CanandmagFaults Unpack(std::span< const uint8_t > data)
::redux::sensors::canandmag::CanandmagStatus Unpack(std::span< const uint8_t > data)
static constexpr size_t GetSize()
Definition: CanandmagStruct.h:56
static constexpr std::string_view GetTypeName()
Definition: CanandmagStruct.h:52
static constexpr std::string_view GetSchema()
Definition: CanandmagStruct.h:58
static void Pack(std::span< uint8_t > data, const ::redux::sensors::canandmag::CanandmagStatus &value)
static void ForEachNested(std::invocable< std::string_view, std::string_view > auto fn)
Definition: CanandmagStruct.h:80