36 auto parts = spy.parts;
38 static std::vector<GUIData> guiData;
43 while (i < parts->
Size()) {
44 std::string headerString((
char*)(*parts)[
i].GetData(), (*parts)[
i].GetSize());
48 auto header = o2::header::get<o2::header::DataHeader*>(headerString.c_str());
49 guiDataPacket.
header = header;
53 int lastPart =
i + payloadParts;
55 while (
i < lastPart) {
57 guiDataPacket.
dataParts.push_back((
char*)(*parts)[
i].GetData());
58 guiDataPacket.
dataLength.push_back((*parts)[
i].GetSize());
61 guiData.push_back(guiDataPacket);
66 int selectedFrame = spy.selectedFrame;
67 int selectedData = spy.selectedData;
70 header = guiData.
size() ? guiData[selectedFrame].header :
nullptr;
72 if (header !=
nullptr) {
74 ImGui::CollapsingHeader(
"Actions", ImGuiTreeNodeFlags_DefaultOpen);
75 if (ImGui::Button(
"Skip 10s")) {
77 spy.enableAfter = uv_now(loop) + 10000;
81 static int selectedHeaderIndex = 0;
85 for (
const auto d : guiData) {
89 std::string
value = std::string(
h->dataOrigin.str) +
" " + std::string(
h->dataDescription.str) +
" " +
std::to_string(
i);
91 bool isSelected = selectedHeaderIndex ==
i;
92 if (ImGui::Selectable(
value.c_str(), isSelected)) {
93 spy.selectedFrame =
i;
94 selectedHeaderIndex =
i;
97 ImGui::SetItemDefaultFocus();
104 ImGui::Text(
"Selected Frame Index: %d", selectedFrame);
105 if (ImGui::CollapsingHeader(
"Header", ImGuiTreeNodeFlags_DefaultOpen)) {
108 ImGui::Text(
"sVersion: %d", header->
sVersion);
112 ImGui::Text(
"Header size: %d", header->
headerSize);
113 ImGui::Text(
"Payload Size: %" PRIu64, header->
payloadSize);
119 ImGui::Text(
"Run Number: %d", header->
runNumber);
125 auto data = guiData[selectedFrame].dataParts[selectedData];
126 auto size = guiData[selectedFrame].dataLength[selectedData];
128 static int rowStart = 0;
129 static int numRows = 10;
131 static bool displayHex =
false;
133 if (ImGui::CollapsingHeader(
"Payload", ImGuiTreeNodeFlags_DefaultOpen)) {
134 ImGui::SliderInt(
"Rows", &numRows, 10, 40);
135 ImGui::SliderInt(
"Starting Row", &rowStart, 0,
size / 4);
136 ImGui::Checkbox(
"Hexadecimal", &displayHex);
137 ImGui::Text(
"Number of Rows, %lu",
size / 4);
138 ImGui::BeginChild(
"##ScrollingRegion", ImVec2(0, 430),
false, ImGuiWindowFlags_HorizontalScrollbar);
140 if (
data !=
nullptr &&
size > 0 && ImGui::BeginTable(
"Data", 5, ImGuiTableFlags_Borders)) {
141 ImGui::TableSetupColumn(
"");
142 ImGui::TableSetupColumn(
"#0");
143 ImGui::TableSetupColumn(
"#1");
144 ImGui::TableSetupColumn(
"#2");
145 ImGui::TableSetupColumn(
"#3");
146 ImGui::TableHeadersRow();
147 for (
int row = rowStart;
row < rowStart + numRows &&
row <
size / 4;
row++) {
148 ImGui::TableNextRow();
149 ImGui::TableSetColumnIndex(0);
150 ImGui::Text(
"%04d",
row * 4);
152 for (
int column = 1; column < 5; column++) {
153 std::stringstream hex;
155 ImGui::TableSetColumnIndex(column);
156 unsigned char dataElem =
data[
row * 4 + (column - 1)];
158 hex << std::hex << (
int)dataElem;
160 hex << std::bitset<8>{
static_cast<unsigned long long>(dataElem)};
163 std::string hexStr = hex.str();
164 if (displayHex && hexStr.length() == 1) {
165 hexStr.insert(0,
"0");
167 ImGui::Text(
"%s", hexStr.c_str());