Skip to content

Commit f6e7845

Browse files
committed
add interface for setting batch rows
1 parent df5bdbe commit f6e7845

8 files changed

+1368
-744
lines changed

Telemetry-SD-Card/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ FetchContent_MakeAvailable(nanoarrow)
3131
set(CMAKE_CXX_STANDARD 20)
3232
add_executable(${PROJECT_NAME} main.cpp)
3333

34+
target_link_libraries(${PROJECT_NAME} mbed-os mbed-storage-sd mbed-storage-fat)
3435
# "SYSTEM" should remove warnings when compiling the generated flatbuffers code
35-
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC include)
36-
target_link_libraries(${PROJECT_NAME} mbed-os mbed-storage-sd mbed-storage-fat nanoarrow nanoarrow_ipc)
36+
# target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC include)
37+
# target_link_libraries(${PROJECT_NAME} mbed-os mbed-storage-sd mbed-storage-fat nanoarrow nanoarrow_ipc)
3738
# target_link_libraries(${PROJECT_NAME} mbed-baremetal mbed-storage-sd mbed-storage-fat)
3839
# target_link_libraries(${PROJECT_NAME} mbed-baremetal mbed-storage-sd mbed-storage-fat nanoarrow nanoarrow_ipc)
3940

Telemetry-SD-Card/dbc_to_cpp.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,23 @@ def generate_cpp_code(signal_to_fsdaq_datatype: dict[str, str], rows: int = 8):
110110
template = template.replace("@COL_NAME_SIZES@", col_name_sizes)
111111
template = template.replace("@COL_NAME_TYPES@", col_name_types)
112112

113-
struct_fields = []
113+
values_struct_fields = []
114+
values_row_struct_fields = []
115+
update_fields_from_row = []
114116
for col_name, fsdaq_type in signal_to_fsdaq_datatype.items():
115117
if fsdaq_type == "b0":
116-
struct_fields.append(" " + "uint8_t" + " " + col_name + "[ROWS/8];")
118+
values_struct_fields.append(" "*4 + "uint8_t" + " " + col_name + "[ROWS/8];")
119+
update_fields_from_row.append(" "*8 + "this->" + col_name + "[idx/8] |= row." + col_name + " << idx;")
117120
else:
118-
struct_fields.append(" " + FSDAQ_TYPE_TO_C_TYPE[fsdaq_type] + " " + col_name + "[ROWS];")
119-
template = template.replace("@STRUCT_FIELDS@", "\n".join(struct_fields))
121+
values_struct_fields.append(" " + FSDAQ_TYPE_TO_C_TYPE[fsdaq_type] + " " + col_name + "[ROWS];")
122+
update_fields_from_row.append(" "*8 + "this->" + col_name + "[idx] = row." + col_name + ";")
123+
values_row_struct_fields.append(" "*4 + FSDAQ_TYPE_TO_C_TYPE[fsdaq_type] + " " + col_name + ";")
124+
template = template.replace("@VALUES_STRUCT_FIELDS@", "\n".join(values_struct_fields))
125+
template = template.replace("@VALUES_ROW_STRUCT_FIELDS@", "\n".join(values_row_struct_fields))
120126

121-
# template = template.replace("@BATCH_COL_REFS@", ", ".join(["vals." + k for k in signal_to_fsdaq_datatype.keys()]))
127+
template = template.replace("@UPDATE_FIELDS_FROM_ROW@", "\n".join(update_fields_from_row))
128+
129+
122130

123131
out_file.write(template)
124132
out_file.close()

Telemetry-SD-Card/fsdaq_encoder_generated_from_dbc.hpp

Lines changed: 452 additions & 1 deletion
Large diffs are not rendered by default.

Telemetry-SD-Card/fsdaq_encoder_generated_from_dbc.hpp.in

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@ static const char *col_names[] = { @COL_NAMES@ };
77
static const uint8_t col_name_sizes[] = { @COL_NAME_SIZES@ };
88
static const char *col_name_types[] = { @COL_NAME_TYPES@ };
99

10+
struct ValuesRow {
11+
@VALUES_ROW_STRUCT_FIELDS@
12+
};
13+
1014
#pragma pack(1)
11-
struct Values {
12-
@STRUCT_FIELDS@
15+
class Values {
16+
@VALUES_STRUCT_FIELDS@
17+
18+
void updateValuesWithRow(ValuesRow row, int idx) {
19+
@UPDATE_FIELDS_FROM_ROW@
20+
}
1321
};
1422
#pragma pack()
1523

0 commit comments

Comments
 (0)