Skip to content

Commit c55d4a5

Browse files
committed
WPIUtil updates
- Struct getTypeString -> getTypeName - DataLog refactor
1 parent f8c9974 commit c55d4a5

File tree

14 files changed

+206
-35
lines changed

14 files changed

+206
-35
lines changed

subprojects/robotpy-wpiutil/gen/DataLog.yml

Lines changed: 127 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ enums:
77
classes:
88
DataLog:
99
subpackage: log
10+
attributes:
11+
kBlockSize:
12+
s_defaultMessageLog:
13+
ignore: true
14+
m_msglog:
15+
ignore: true
1016
methods:
1117
DataLog:
12-
overloads:
13-
std::string_view, std::string_view, double, std::string_view:
14-
wpi::Logger&, std::string_view, std::string_view, double, std::string_view:
15-
ignore: true
16-
std::function<void (std::span<const uint8_t> data)>, double, std::string_view:
17-
wpi::Logger&, std::function<void (std::span<const uint8_t> data)>, double, std::string_view:
18-
ignore: true
19-
SetFilename:
18+
ignore: true
2019
Flush:
2120
Pause:
2221
Resume:
@@ -63,8 +62,15 @@ classes:
6362
int, std::span<const std::string>, int64_t:
6463
ignore: true
6564
int, std::span<const std::string_view>, int64_t:
66-
int, std::span<const WPI_DataLog_String>, int64_t:
65+
int, std::span<const struct WPI_String>, int64_t:
6766
ignore: true
67+
StartFile:
68+
FlushBufs:
69+
ignore: true
70+
ReleaseBufs:
71+
ignore: true
72+
BufferHalfFull:
73+
BufferFull:
6874
DataLogEntry:
6975
subpackage: log
7076
force_no_trampoline: true
@@ -76,6 +82,23 @@ classes:
7682
"":
7783
ignore: true
7884
DataLog&, std::string_view, std::string_view, std::string_view, int64_t:
85+
DataLogValueEntryImpl:
86+
template_params:
87+
- T
88+
force_no_trampoline: true
89+
attributes:
90+
m_mutex:
91+
ignore: true
92+
m_lastValue:
93+
ignore: true
94+
methods:
95+
HasLastValue:
96+
GetLastValue:
97+
DataLogValueEntryImpl:
98+
overloads:
99+
"":
100+
ignore: true
101+
DataLog&, std::string_view, std::string_view, std::string_view, int64_t:
79102
RawLogEntry:
80103
subpackage: log
81104
force_no_trampoline: true
@@ -90,6 +113,7 @@ classes:
90113
DataLog&, std::string_view, std::string_view, int64_t:
91114
DataLog&, std::string_view, std::string_view, std::string_view, int64_t:
92115
Append:
116+
Update:
93117
BooleanLogEntry:
94118
subpackage: log
95119
force_no_trampoline: true
@@ -103,6 +127,7 @@ classes:
103127
DataLog&, std::string_view, int64_t:
104128
DataLog&, std::string_view, std::string_view, int64_t:
105129
Append:
130+
Update:
106131
IntegerLogEntry:
107132
subpackage: log
108133
force_no_trampoline: true
@@ -116,6 +141,7 @@ classes:
116141
DataLog&, std::string_view, int64_t:
117142
DataLog&, std::string_view, std::string_view, int64_t:
118143
Append:
144+
Update:
119145
FloatLogEntry:
120146
subpackage: log
121147
force_no_trampoline: true
@@ -129,6 +155,7 @@ classes:
129155
DataLog&, std::string_view, int64_t:
130156
DataLog&, std::string_view, std::string_view, int64_t:
131157
Append:
158+
Update:
132159
DoubleLogEntry:
133160
subpackage: log
134161
force_no_trampoline: true
@@ -142,6 +169,7 @@ classes:
142169
DataLog&, std::string_view, int64_t:
143170
DataLog&, std::string_view, std::string_view, int64_t:
144171
Append:
172+
Update:
145173
StringLogEntry:
146174
subpackage: log
147175
force_no_trampoline: true
@@ -156,6 +184,7 @@ classes:
156184
DataLog&, std::string_view, std::string_view, int64_t:
157185
DataLog&, std::string_view, std::string_view, std::string_view, int64_t:
158186
Append:
187+
Update:
159188
BooleanArrayLogEntry:
160189
subpackage: log
161190
force_no_trampoline: true
@@ -179,6 +208,16 @@ classes:
179208
ignore: true
180209
std::span<const uint8_t>, int64_t:
181210
ignore: true
211+
Update:
212+
overloads:
213+
std::span<const bool>, int64_t:
214+
std::initializer_list<bool>, int64_t:
215+
ignore: true
216+
std::span<const int>, int64_t:
217+
std::initializer_list<int>, int64_t:
218+
ignore: true
219+
std::span<const uint8_t>, int64_t:
220+
ignore: true
182221
IntegerArrayLogEntry:
183222
subpackage: log
184223
force_no_trampoline: true
@@ -196,6 +235,11 @@ classes:
196235
std::span<const int64_t>, int64_t:
197236
std::initializer_list<int64_t>, int64_t:
198237
ignore: true
238+
Update:
239+
overloads:
240+
std::span<const int64_t>, int64_t:
241+
std::initializer_list<int64_t>, int64_t:
242+
ignore: true
199243
FloatArrayLogEntry:
200244
subpackage: log
201245
force_no_trampoline: true
@@ -213,6 +257,11 @@ classes:
213257
std::span<const float>, int64_t:
214258
std::initializer_list<float>, int64_t:
215259
ignore: true
260+
Update:
261+
overloads:
262+
std::span<const float>, int64_t:
263+
std::initializer_list<float>, int64_t:
264+
ignore: true
216265
DoubleArrayLogEntry:
217266
subpackage: log
218267
force_no_trampoline: true
@@ -230,6 +279,11 @@ classes:
230279
std::span<const double>, int64_t:
231280
std::initializer_list<double>, int64_t:
232281
ignore: true
282+
Update:
283+
overloads:
284+
std::span<const double>, int64_t:
285+
std::initializer_list<double>, int64_t:
286+
ignore: true
233287
StringArrayLogEntry:
234288
subpackage: log
235289
force_no_trampoline: true
@@ -249,6 +303,13 @@ classes:
249303
std::span<const std::string_view>, int64_t:
250304
std::initializer_list<std::string_view>, int64_t:
251305
ignore: true
306+
Update:
307+
overloads:
308+
std::span<const std::string>, int64_t:
309+
ignore: true
310+
std::span<const std::string_view>, int64_t:
311+
std::initializer_list<std::string_view>, int64_t:
312+
ignore: true
252313
StructLogEntry:
253314
force_no_trampoline: true
254315
template_params:
@@ -335,4 +396,60 @@ templates:
335396
subpackage: log
336397
params:
337398
- WPyStruct
338-
- WPyStructInfo
399+
- WPyStructInfo
400+
401+
_RawLogEntryImpl:
402+
qualname: wpi::log::DataLogValueEntryImpl
403+
subpackage: log
404+
params:
405+
- std::vector<uint8_t>
406+
_BooleanLogEntryImpl:
407+
qualname: wpi::log::DataLogValueEntryImpl
408+
subpackage: log
409+
params:
410+
- bool
411+
_IntegerLogEntryImpl:
412+
qualname: wpi::log::DataLogValueEntryImpl
413+
subpackage: log
414+
params:
415+
- int64_t
416+
_FloatLogEntryImpl:
417+
qualname: wpi::log::DataLogValueEntryImpl
418+
subpackage: log
419+
params:
420+
- float
421+
_DoubleLogEntryImpl:
422+
qualname: wpi::log::DataLogValueEntryImpl
423+
subpackage: log
424+
params:
425+
- double
426+
_StringLogEntryImpl:
427+
qualname: wpi::log::DataLogValueEntryImpl
428+
subpackage: log
429+
params:
430+
- std::string
431+
_BooleanArrayLogEntryImpl:
432+
qualname: wpi::log::DataLogValueEntryImpl
433+
subpackage: log
434+
params:
435+
- std::vector<int>
436+
_IntegerArrayLogEntryImpl:
437+
qualname: wpi::log::DataLogValueEntryImpl
438+
subpackage: log
439+
params:
440+
- std::vector<int64_t>
441+
_FloatArrayLogEntryImpl:
442+
qualname: wpi::log::DataLogValueEntryImpl
443+
subpackage: log
444+
params:
445+
- std::vector<float>
446+
_DoubleArrayLogEntryImpl:
447+
qualname: wpi::log::DataLogValueEntryImpl
448+
subpackage: log
449+
params:
450+
- std::vector<double>
451+
_StringArrayLogEntryImpl:
452+
qualname: wpi::log::DataLogValueEntryImpl
453+
subpackage: log
454+
params:
455+
- std::vector<std::string>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
3+
classes:
4+
DataLogBackgroundWriter:
5+
methods:
6+
DataLogBackgroundWriter:
7+
overloads:
8+
std::string_view, std::string_view, double, std::string_view:
9+
wpi::Logger&, std::string_view, std::string_view, double, std::string_view:
10+
ignore: true
11+
std::function<void (std::span<const uint8_t> data)>, double, std::string_view:
12+
wpi::Logger&, std::function<void (std::span<const uint8_t> data)>, double, std::string_view:
13+
ignore: true
14+
SetFilename:
15+
Flush:
16+
Pause:
17+
Resume:
18+
Stop:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
3+
classes:
4+
DataLogWriter:
5+
methods:
6+
DataLogWriter:
7+
overloads:
8+
std::string_view, std::error_code&, std::string_view:
9+
cpp_code: |
10+
[](std::string_view filename, std::string_view extraHeader) {
11+
std::error_code ec;
12+
auto writer = std::make_unique<DataLogWriter>(filename, ec, extraHeader);
13+
if (ec) {
14+
throw std::system_error(ec);
15+
}
16+
return writer;
17+
}
18+
param_override:
19+
ec:
20+
ignore: true
21+
wpi::Logger&, std::string_view, std::error_code&, std::string_view:
22+
ignore: true
23+
std::unique_ptr<wpi::raw_ostream>, std::string_view:
24+
ignore: true
25+
wpi::Logger&, std::unique_ptr<wpi::raw_ostream>, std::string_view:
26+
ignore: true
27+
Flush:
28+
Stop:
29+
GetStream:
30+
ignore: true

subprojects/robotpy-wpiutil/gen/WPyStruct.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ functions:
22
forEachNested:
33
subpackage: wpistruct
44
no_release_gil: true
5-
getTypeString:
5+
getTypeName:
66
subpackage: wpistruct
77
no_release_gil: true
88
getSchema:

subprojects/robotpy-wpiutil/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ libs = ["wpiutil"]
4343
# wpi
4444
DataLog = "wpi/DataLog.h"
4545
DataLogReader = "wpi/DataLogReader.h"
46+
DataLogBackgroundWriter = "wpi/DataLogBackgroundWriter.h"
47+
DataLogWriter = "wpi/DataLogWriter.h"
4648
StackTrace = "wpi/StackTrace.h"
4749
Synchronization = "wpi/Synchronization.h"
4850

subprojects/robotpy-wpiutil/tests/cpp/wpiutil_test/struct_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct ThingA {
1616
};
1717

1818
template <> struct wpi::Struct<ThingA> {
19-
static constexpr std::string_view GetTypeString() { return "struct:ThingA"; }
19+
static constexpr std::string_view GetTypeName() { return "ThingA"; }
2020
static constexpr size_t GetSize() { return 1; }
2121
static constexpr std::string_view GetSchema() { return "uint8 value"; }
2222
static ThingA Unpack(std::span<const uint8_t> data) {
@@ -41,7 +41,7 @@ struct Outer {
4141

4242
template <>
4343
struct wpi::Struct<Outer> {
44-
static constexpr std::string_view GetTypeString() { return "struct:Outer"; }
44+
static constexpr std::string_view GetTypeName() { return "Outer"; }
4545
static constexpr size_t GetSize() { return wpi::GetStructSize<ThingA>() + 4; }
4646
static constexpr std::string_view GetSchema() {
4747
return "ThingA inner; int32 c";

subprojects/robotpy-wpiutil/tests/test_struct.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _fn(*args):
3131

3232

3333
def test_get_type_string():
34-
assert wpistruct.getTypeString(module.ThingA) == "struct:ThingA"
34+
assert wpistruct.getTypeName(module.ThingA) == "ThingA"
3535

3636

3737
def test_get_schema():
@@ -89,7 +89,7 @@ def _fn(*args):
8989

9090

9191
def test_nested_get_type_string():
92-
assert wpistruct.getTypeString(module.ThingA) == "struct:ThingA"
92+
assert wpistruct.getTypeName(module.ThingA) == "ThingA"
9393

9494

9595
def test_nested_get_schema():
@@ -140,7 +140,7 @@ def _fn(*args):
140140

141141

142142
def test_user_get_type_string():
143-
assert wpistruct.getTypeString(MyStruct) == "struct:mystruct"
143+
assert wpistruct.getTypeName(MyStruct) == "mystruct"
144144

145145

146146
def test_user_get_schema():
@@ -202,7 +202,7 @@ def _fn(*args):
202202

203203

204204
def test_user_nested_get_type_string():
205-
assert wpistruct.getTypeString(Outer) == "struct:Outer"
205+
assert wpistruct.getTypeName(Outer) == "Outer"
206206

207207

208208
def test_user_nested_get_schema():

subprojects/robotpy-wpiutil/wpiutil/log/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
StartRecordData,
1818
StringArrayLogEntry,
1919
StringLogEntry,
20+
StructArrayLogEntry,
21+
StructLogEntry,
2022
)
2123

2224
__all__ = [
@@ -37,4 +39,6 @@
3739
"StartRecordData",
3840
"StringArrayLogEntry",
3941
"StringLogEntry",
42+
"StructArrayLogEntry",
43+
"StructLogEntry",
4044
]

0 commit comments

Comments
 (0)