2023-01-18 23:17:24 +01:00
|
|
|
#include "module_stdc_parser.h"
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include "logger.h"
|
|
|
|
|
#include <filesystem>
|
|
|
|
|
#include "imgui/imgui.h"
|
|
|
|
|
#include "common/utils.h"
|
2023-01-20 17:25:47 +01:00
|
|
|
#include "pkt_parser.h"
|
2023-01-21 22:49:35 +01:00
|
|
|
#include "msg_parser.h"
|
2023-01-22 00:34:22 +01:00
|
|
|
#include "egc_parser.h"
|
2023-01-18 23:17:24 +01:00
|
|
|
|
|
|
|
|
namespace inmarsat
|
|
|
|
|
{
|
|
|
|
|
namespace stdc
|
|
|
|
|
{
|
|
|
|
|
STDCParserModule::STDCParserModule(std::string input_file, std::string output_file_hint, nlohmann::json parameters) : ProcessingModule(input_file, output_file_hint, parameters)
|
|
|
|
|
{
|
2023-01-28 23:55:30 +01:00
|
|
|
buffer = new uint8_t[FRAME_SIZE_BYTES * 4];
|
|
|
|
|
memset(buffer, 0, FRAME_SIZE_BYTES * 4);
|
2023-01-29 02:27:58 +01:00
|
|
|
|
|
|
|
|
if (parameters.contains("udp_sinks"))
|
|
|
|
|
{
|
|
|
|
|
for (auto &sinks : parameters["udp_sinks"].items())
|
|
|
|
|
{
|
|
|
|
|
std::string address = sinks.value()["address"].get<std::string>();
|
|
|
|
|
int port = sinks.value()["port"].get<int>();
|
|
|
|
|
udp_clients.push_back(std::make_shared<net::UDPClient>((char *)address.c_str(), port));
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-30 11:50:22 +01:00
|
|
|
|
|
|
|
|
if (parameters.contains("save_files"))
|
|
|
|
|
do_save_files = parameters["save_files"].get<bool>();
|
|
|
|
|
else
|
|
|
|
|
do_save_files = true;
|
2023-01-18 23:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<ModuleDataType> STDCParserModule::getInputTypes()
|
|
|
|
|
{
|
|
|
|
|
return {DATA_FILE, DATA_STREAM};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<ModuleDataType> STDCParserModule::getOutputTypes()
|
|
|
|
|
{
|
|
|
|
|
return {DATA_FILE};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
STDCParserModule::~STDCParserModule()
|
|
|
|
|
{
|
|
|
|
|
delete[] buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 17:25:47 +01:00
|
|
|
std::string timestampToTod(time_t time_v)
|
|
|
|
|
{
|
|
|
|
|
std::tm *timeReadable = gmtime(&time_v);
|
|
|
|
|
return (timeReadable->tm_hour > 9 ? std::to_string(timeReadable->tm_hour) : "0" + std::to_string(timeReadable->tm_hour)) + ":" + // Hour HH
|
|
|
|
|
(timeReadable->tm_min > 9 ? std::to_string(timeReadable->tm_min) : "0" + std::to_string(timeReadable->tm_min)) + ":" + // Minutes mm
|
|
|
|
|
(timeReadable->tm_sec > 9 ? std::to_string(timeReadable->tm_sec) : "0" + std::to_string(timeReadable->tm_sec)); // Seconds ss
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-29 02:27:58 +01:00
|
|
|
void STDCParserModule::process_final_pkt(nlohmann::json &msg)
|
2023-01-21 22:49:35 +01:00
|
|
|
{
|
2023-01-29 02:27:58 +01:00
|
|
|
// UDP
|
|
|
|
|
{
|
|
|
|
|
for (auto &c : udp_clients)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
std::string m = msg.dump();
|
|
|
|
|
c->send((uint8_t *)m.data(), m.size());
|
|
|
|
|
}
|
|
|
|
|
catch (std::exception &e)
|
|
|
|
|
{
|
2023-05-08 23:08:34 +02:00
|
|
|
logger->error("Error sending to UDP! %s", e.what());
|
2023-01-29 02:27:58 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-21 22:49:35 +01:00
|
|
|
|
2023-01-29 02:27:58 +01:00
|
|
|
// File
|
2023-01-30 11:50:22 +01:00
|
|
|
if (do_save_files)
|
2023-01-29 02:27:58 +01:00
|
|
|
{
|
|
|
|
|
std::string pkt_name = get_id_name(get_packet_frm_id(msg));
|
|
|
|
|
if (msg.contains("pkt_name"))
|
|
|
|
|
pkt_name = msg["pkt_name"];
|
2023-01-21 22:49:35 +01:00
|
|
|
|
2023-01-29 02:27:58 +01:00
|
|
|
std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/" + pkt_name;
|
2023-01-21 22:49:35 +01:00
|
|
|
|
2023-01-29 02:27:58 +01:00
|
|
|
if (!std::filesystem::exists(directory))
|
|
|
|
|
std::filesystem::create_directory(directory);
|
2023-01-21 22:49:35 +01:00
|
|
|
|
2023-01-29 02:27:58 +01:00
|
|
|
double time_d = msg["timestamp"].get<double>();
|
|
|
|
|
time_t time_v = time_d;
|
|
|
|
|
std::tm *timeReadable = gmtime(&time_v);
|
|
|
|
|
|
|
|
|
|
std::string utc_filename = std::to_string(timeReadable->tm_year + 1900) + // Year yyyy
|
|
|
|
|
(timeReadable->tm_mon + 1 > 9 ? std::to_string(timeReadable->tm_mon + 1) : "0" + std::to_string(timeReadable->tm_mon + 1)) + // Month MM
|
|
|
|
|
(timeReadable->tm_mday > 9 ? std::to_string(timeReadable->tm_mday) : "0" + std::to_string(timeReadable->tm_mday)) + "T" + // Day dd
|
|
|
|
|
(timeReadable->tm_hour > 9 ? std::to_string(timeReadable->tm_hour) : "0" + std::to_string(timeReadable->tm_hour)) + // Hour HH
|
|
|
|
|
(timeReadable->tm_min > 9 ? std::to_string(timeReadable->tm_min) : "0" + std::to_string(timeReadable->tm_min)) + // Minutes mm
|
|
|
|
|
(timeReadable->tm_sec > 9 ? std::to_string(timeReadable->tm_sec) : "0" + std::to_string(timeReadable->tm_sec)) + "Z"; // Seconds ss
|
|
|
|
|
|
|
|
|
|
std::ofstream outf(directory + "/" + utc_filename + ".json", std::ios::binary);
|
|
|
|
|
outf << msg.dump(4);
|
|
|
|
|
outf.close();
|
|
|
|
|
}
|
2023-01-21 22:49:35 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-18 23:17:24 +01:00
|
|
|
void STDCParserModule::process()
|
|
|
|
|
{
|
|
|
|
|
if (input_data_type == DATA_FILE)
|
|
|
|
|
filesize = getFilesize(d_input_file);
|
|
|
|
|
else
|
|
|
|
|
filesize = 0;
|
|
|
|
|
if (input_data_type == DATA_FILE)
|
|
|
|
|
data_in = std::ifstream(d_input_file, std::ios::binary);
|
|
|
|
|
|
|
|
|
|
logger->info("Using input frames " + d_input_file);
|
|
|
|
|
|
2023-01-20 17:25:47 +01:00
|
|
|
STDPacketParser pkt_parser;
|
2023-01-21 22:49:35 +01:00
|
|
|
MessageParser msg_parser;
|
2023-01-22 00:34:22 +01:00
|
|
|
EGCMessageParser egc_parser;
|
2023-01-20 17:25:47 +01:00
|
|
|
|
|
|
|
|
pkt_parser.on_packet = [&](nlohmann::json msg)
|
|
|
|
|
{
|
2023-01-21 22:49:35 +01:00
|
|
|
double time_d = msg["timestamp"].get<double>();
|
2023-01-27 14:42:12 +01:00
|
|
|
int id = get_packet_frm_id(msg);
|
|
|
|
|
|
|
|
|
|
if (id == pkts::PacketBulletinBoard::FRM_ID)
|
2023-01-22 00:34:22 +01:00
|
|
|
{
|
2023-01-21 22:49:35 +01:00
|
|
|
msg_parser.push_current_time(time_d);
|
2023-01-25 15:33:16 +01:00
|
|
|
// egc_parser.push_current_time(time_d);
|
2023-01-22 00:34:22 +01:00
|
|
|
}
|
2023-01-20 17:25:47 +01:00
|
|
|
|
2023-01-27 14:42:12 +01:00
|
|
|
if (id != pkts::PacketMessageData::FRM_ID)
|
2023-01-29 02:27:58 +01:00
|
|
|
process_final_pkt(msg);
|
2023-01-20 17:25:47 +01:00
|
|
|
|
2023-01-27 14:42:12 +01:00
|
|
|
if (id == pkts::PacketMessageData::FRM_ID)
|
2023-01-21 22:49:35 +01:00
|
|
|
{
|
2023-01-22 14:50:57 +01:00
|
|
|
std::string m = msg["message"].get<std::string>();
|
2023-12-28 22:22:35 -05:00
|
|
|
logger->info("Message : \n%s", m.c_str());
|
2023-01-22 14:50:57 +01:00
|
|
|
if (m != "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ-!") // Remove those periodic ones
|
|
|
|
|
msg_parser.push_message(msg);
|
2023-01-21 22:49:35 +01:00
|
|
|
}
|
2023-01-27 14:42:12 +01:00
|
|
|
else if (id == pkts::PacketEGCDoubleHeader1::FRM_ID)
|
2023-01-22 00:34:22 +01:00
|
|
|
{
|
2023-12-28 22:22:35 -05:00
|
|
|
logger->info("EGC Double Header 1 : \n%s", msg["message"].get<std::string>().c_str());
|
2023-01-22 00:34:22 +01:00
|
|
|
egc_parser.push_message(msg);
|
|
|
|
|
}
|
2023-01-27 14:42:12 +01:00
|
|
|
else if (id == pkts::PacketEGCDoubleHeader2::FRM_ID)
|
2023-01-22 00:34:22 +01:00
|
|
|
{
|
2023-12-28 22:22:35 -05:00
|
|
|
logger->info("EGC Double Header 2 : \n%s", msg["message"].get<std::string>().c_str());
|
2023-01-22 00:34:22 +01:00
|
|
|
egc_parser.push_message(msg);
|
|
|
|
|
}
|
2023-01-20 18:06:06 +01:00
|
|
|
else
|
2023-01-27 14:42:12 +01:00
|
|
|
logger->info("Packet : " + get_id_name(id));
|
2023-01-20 17:25:47 +01:00
|
|
|
|
2023-01-31 20:40:37 +01:00
|
|
|
if (is_gui)
|
|
|
|
|
{
|
|
|
|
|
pkt_history_mtx.lock();
|
|
|
|
|
pkt_history.push_back(msg);
|
|
|
|
|
if (pkt_history.size() > 500)
|
2023-04-19 21:07:41 +02:00
|
|
|
{
|
2023-01-31 20:40:37 +01:00
|
|
|
pkt_history.erase(pkt_history.begin());
|
2023-04-19 21:07:41 +02:00
|
|
|
pkt_history.shrink_to_fit();
|
|
|
|
|
}
|
2023-01-31 20:40:37 +01:00
|
|
|
pkt_history_mtx.unlock();
|
|
|
|
|
}
|
2023-01-20 17:25:47 +01:00
|
|
|
|
2023-01-27 14:42:12 +01:00
|
|
|
// logger->info("Packet IDK : \n" + msg.dump(4));
|
2023-01-20 17:25:47 +01:00
|
|
|
};
|
|
|
|
|
|
2023-01-21 22:49:35 +01:00
|
|
|
msg_parser.on_message = [&](nlohmann::json msg)
|
|
|
|
|
{
|
2023-01-27 14:42:12 +01:00
|
|
|
msg["pkt_name"] = "Full Message";
|
|
|
|
|
|
2023-01-29 02:27:58 +01:00
|
|
|
process_final_pkt(msg);
|
2023-01-21 22:49:35 +01:00
|
|
|
|
2023-12-28 22:22:35 -05:00
|
|
|
logger->info("Full Message : \n%s", msg["message"].get<std::string>().c_str());
|
2023-01-21 22:49:35 +01:00
|
|
|
|
2023-01-31 20:40:37 +01:00
|
|
|
if (is_gui)
|
|
|
|
|
{
|
|
|
|
|
pkt_history_mtx.lock();
|
|
|
|
|
pkt_history_msg.push_back(msg);
|
|
|
|
|
if (pkt_history_msg.size() > 100)
|
2023-04-19 21:07:41 +02:00
|
|
|
{
|
|
|
|
|
pkt_history.erase(pkt_history.begin());
|
|
|
|
|
pkt_history.shrink_to_fit();
|
|
|
|
|
}
|
2023-01-31 20:40:37 +01:00
|
|
|
pkt_history_mtx.unlock();
|
|
|
|
|
}
|
2023-01-21 22:49:35 +01:00
|
|
|
};
|
|
|
|
|
|
2023-01-22 00:34:22 +01:00
|
|
|
egc_parser.on_message = [&](nlohmann::json msg)
|
|
|
|
|
{
|
2023-01-27 14:42:12 +01:00
|
|
|
msg["pkt_name"] = "EGC Message";
|
2023-01-22 00:34:22 +01:00
|
|
|
|
2023-01-29 02:27:58 +01:00
|
|
|
process_final_pkt(msg);
|
2023-01-22 00:34:22 +01:00
|
|
|
|
2023-12-28 22:22:35 -05:00
|
|
|
logger->info("Full EGC Message : \n%s", msg["message"].get<std::string>().c_str());
|
2023-01-22 00:34:22 +01:00
|
|
|
|
2023-01-31 20:40:37 +01:00
|
|
|
if (is_gui)
|
|
|
|
|
{
|
|
|
|
|
pkt_history_mtx.lock();
|
|
|
|
|
pkt_history_egc.push_back(msg);
|
|
|
|
|
if (pkt_history_egc.size() > 100)
|
2023-04-19 21:07:41 +02:00
|
|
|
{
|
2023-01-31 20:40:37 +01:00
|
|
|
pkt_history_egc.erase(pkt_history_egc.begin());
|
2023-04-19 21:07:41 +02:00
|
|
|
pkt_history.shrink_to_fit();
|
|
|
|
|
}
|
2023-01-31 20:40:37 +01:00
|
|
|
pkt_history_mtx.unlock();
|
|
|
|
|
}
|
2023-01-22 00:34:22 +01:00
|
|
|
};
|
|
|
|
|
|
2023-01-18 23:17:24 +01:00
|
|
|
time_t lastTime = 0;
|
|
|
|
|
while (input_data_type == DATA_FILE ? !data_in.eof() : input_active.load())
|
|
|
|
|
{
|
|
|
|
|
// Read a buffer
|
|
|
|
|
if (input_data_type == DATA_FILE)
|
|
|
|
|
data_in.read((char *)buffer, FRAME_SIZE_BYTES);
|
|
|
|
|
else
|
|
|
|
|
input_fifo->read((uint8_t *)buffer, FRAME_SIZE_BYTES);
|
|
|
|
|
|
2023-01-22 13:02:37 +01:00
|
|
|
last_pkt_count = buffer[2] << 8 | buffer[3];
|
|
|
|
|
|
2023-01-20 17:25:47 +01:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// logger->critical("new pkt");
|
|
|
|
|
pkt_parser.parse_main_pkt(buffer);
|
|
|
|
|
}
|
|
|
|
|
catch (std::exception &e)
|
|
|
|
|
{
|
2023-05-08 23:08:34 +02:00
|
|
|
logger->error("Error processing STD-C frame %s", e.what());
|
2023-01-20 17:25:47 +01:00
|
|
|
}
|
2023-01-18 23:17:24 +01:00
|
|
|
|
|
|
|
|
if (input_data_type == DATA_FILE)
|
|
|
|
|
progress = data_in.tellg();
|
|
|
|
|
|
|
|
|
|
if (time(NULL) % 10 == 0 && lastTime != time(NULL))
|
|
|
|
|
{
|
|
|
|
|
lastTime = time(NULL);
|
2023-11-15 16:08:17 -05:00
|
|
|
logger->info("Progress " + std::to_string(round(((double)progress / (double)filesize) * 1000.0) / 10.0) + "%%");
|
2023-01-18 23:17:24 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-25 15:33:16 +01:00
|
|
|
egc_parser.force_finish();
|
|
|
|
|
|
2023-01-18 23:17:24 +01:00
|
|
|
if (input_data_type == DATA_FILE)
|
|
|
|
|
data_in.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void STDCParserModule::drawUI(bool window)
|
|
|
|
|
{
|
2023-01-31 20:40:37 +01:00
|
|
|
is_gui = true;
|
|
|
|
|
|
2023-01-18 23:17:24 +01:00
|
|
|
ImGui::Begin("Inmarsat STD-C Parser", NULL, window ? 0 : NOWINDOW_FLAGS);
|
|
|
|
|
|
2023-01-20 17:25:47 +01:00
|
|
|
ImGui::Text("Decoded packets can be seen in a floating window.");
|
2023-02-09 15:57:29 +01:00
|
|
|
ImGui::Text("Do remember you should nor read nor keep messages that are\nnot intended for you.");
|
2023-01-22 13:02:37 +01:00
|
|
|
|
|
|
|
|
ImGui::Spacing();
|
|
|
|
|
ImGui::Text("Last packet count : ");
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
ImGui::TextColored(ImColor(0, 255, 0), "%d", last_pkt_count);
|
2023-01-20 17:25:47 +01:00
|
|
|
|
|
|
|
|
if (input_data_type == DATA_FILE)
|
2023-11-15 16:08:17 -05:00
|
|
|
ImGui::ProgressBar((double)progress / (double)filesize, ImVec2(ImGui::GetWindowWidth() - 10, 20 * ui_scale));
|
2023-01-18 23:17:24 +01:00
|
|
|
|
|
|
|
|
ImGui::End();
|
2023-01-20 17:25:47 +01:00
|
|
|
|
|
|
|
|
if (input_data_type != DATA_FILE)
|
|
|
|
|
{
|
|
|
|
|
ImGui::Begin("STD-C Packets", NULL, ImGuiWindowFlags_HorizontalScrollbar);
|
|
|
|
|
|
|
|
|
|
pkt_history_mtx.lock();
|
2023-01-21 22:49:35 +01:00
|
|
|
ImGui::BeginTabBar("##sdtmessagestabbar");
|
|
|
|
|
if (ImGui::BeginTabItem("Messages"))
|
|
|
|
|
{
|
|
|
|
|
ImGui::BeginTable("##stdmessagetable", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit);
|
|
|
|
|
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_NoResize, 150 * ui_scale);
|
|
|
|
|
ImGui::TableSetupColumn("Timestamp", ImGuiTableColumnFlags_NoResize, 75 * ui_scale);
|
|
|
|
|
ImGui::TableSetupColumn("Contents", 0, -1);
|
|
|
|
|
ImGui::TableHeadersRow();
|
|
|
|
|
|
|
|
|
|
for (int i = pkt_history_msg.size() - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
auto &msg = pkt_history_msg[i];
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-01-28 22:58:43 +01:00
|
|
|
int id = get_packet_frm_id(msg);
|
2023-01-21 22:49:35 +01:00
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
2023-01-28 22:58:43 +01:00
|
|
|
ImGui::TextColored(ImColor(160, 160, 255), "%s", get_id_name(id).c_str());
|
2023-01-21 22:49:35 +01:00
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
|
ImGui::TextColored(ImColor(255, 255, 0), "%s", timestampToTod(msg["timestamp"].get<double>()).c_str());
|
|
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
ImGui::TextColored(ImColor(0, 255, 0), "%s", msg["message"].get<std::string>().c_str());
|
|
|
|
|
}
|
2023-08-22 19:34:32 -04:00
|
|
|
catch (std::exception&)
|
2023-01-22 00:34:22 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
|
ImGui::EndTabItem();
|
|
|
|
|
}
|
|
|
|
|
if (ImGui::BeginTabItem("EGC Messages"))
|
|
|
|
|
{
|
|
|
|
|
ImGui::BeginTable("##stdmessagetable", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit);
|
|
|
|
|
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_NoResize, 150 * ui_scale);
|
|
|
|
|
ImGui::TableSetupColumn("Timestamp", ImGuiTableColumnFlags_NoResize, 75 * ui_scale);
|
|
|
|
|
ImGui::TableSetupColumn("Contents", 0, -1);
|
|
|
|
|
ImGui::TableHeadersRow();
|
|
|
|
|
|
|
|
|
|
for (int i = pkt_history_egc.size() - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
auto &msg = pkt_history_egc[i];
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-01-28 22:58:43 +01:00
|
|
|
int id = get_packet_frm_id(msg);
|
2023-01-22 00:34:22 +01:00
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
2023-01-28 22:58:43 +01:00
|
|
|
ImGui::TextColored(ImColor(160, 160, 255), "%s", get_id_name(id).c_str());
|
2023-01-22 00:34:22 +01:00
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
|
ImGui::TextColored(ImColor(255, 255, 0), "%s", timestampToTod(msg["timestamp"].get<double>()).c_str());
|
|
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
ImGui::TextColored(ImColor(0, 255, 0), "%s", msg["message"].get<std::string>().c_str());
|
|
|
|
|
}
|
2023-08-22 19:34:32 -04:00
|
|
|
catch (std::exception&)
|
2023-01-21 22:49:35 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
|
ImGui::EndTabItem();
|
|
|
|
|
}
|
|
|
|
|
if (ImGui::BeginTabItem("Packets"))
|
2023-01-20 17:25:47 +01:00
|
|
|
{
|
2023-01-21 22:49:35 +01:00
|
|
|
ImGui::BeginTable("##stdmessagetable", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit);
|
2023-01-20 17:25:47 +01:00
|
|
|
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_NoResize, 150 * ui_scale);
|
|
|
|
|
ImGui::TableSetupColumn("Timestamp", ImGuiTableColumnFlags_NoResize, 75 * ui_scale);
|
2023-01-20 17:58:21 +01:00
|
|
|
ImGui::TableSetupColumn("Contents", 0, -1);
|
2023-01-20 17:25:47 +01:00
|
|
|
ImGui::TableHeadersRow();
|
|
|
|
|
|
|
|
|
|
for (int i = pkt_history.size() - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
auto &msg = pkt_history[i];
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-01-27 15:33:11 +01:00
|
|
|
int id = get_packet_frm_id(msg);
|
|
|
|
|
if (id == pkts::PacketMessageData::FRM_ID)
|
2023-01-20 17:25:47 +01:00
|
|
|
{
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
2023-01-27 15:33:11 +01:00
|
|
|
ImGui::TextColored(ImColor(160, 160, 255), "%s", get_id_name(id).c_str());
|
2023-01-20 17:25:47 +01:00
|
|
|
ImGui::TableSetColumnIndex(1);
|
2023-01-20 17:58:21 +01:00
|
|
|
ImGui::TextColored(ImColor(255, 255, 0), "%s", timestampToTod(msg["timestamp"].get<double>()).c_str());
|
2023-01-20 17:25:47 +01:00
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
ImGui::TextColored(ImColor(0, 255, 0), "%s", msg["message"].get<std::string>().c_str());
|
|
|
|
|
}
|
2023-01-27 15:46:27 +01:00
|
|
|
else if (id == pkts::PacketEGCDoubleHeader1::FRM_ID || id == pkts::PacketEGCDoubleHeader2::FRM_ID)
|
2023-01-20 18:06:06 +01:00
|
|
|
{
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
2023-01-27 15:47:14 +01:00
|
|
|
ImGui::TextColored(ImColor(160, 160, 255), "%s", get_id_name(id).c_str());
|
2023-01-20 18:06:06 +01:00
|
|
|
ImGui::TableSetColumnIndex(1);
|
|
|
|
|
ImGui::TextColored(ImColor(255, 255, 0), "%s", timestampToTod(msg["timestamp"].get<double>()).c_str());
|
|
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
ImGui::TextColored(ImColor(255, 0, 0), "%s", msg["message"].get<std::string>().c_str());
|
|
|
|
|
}
|
2023-01-21 22:49:35 +01:00
|
|
|
else
|
2023-01-20 17:25:47 +01:00
|
|
|
{
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
|
ImGui::TableSetColumnIndex(0);
|
2023-01-27 15:47:14 +01:00
|
|
|
ImGui::TextColored(ImColor(160, 160, 255), "%s", get_id_name(id).c_str());
|
2023-01-20 17:25:47 +01:00
|
|
|
ImGui::TableSetColumnIndex(1);
|
2023-01-20 17:58:21 +01:00
|
|
|
ImGui::TextColored(ImColor(255, 255, 0), "%s", timestampToTod(msg["timestamp"].get<double>()).c_str());
|
2023-01-20 17:25:47 +01:00
|
|
|
ImGui::TableSetColumnIndex(2);
|
|
|
|
|
ImGui::TextColored(ImColor(255, 255, 255), "%s", msg.dump().c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-22 19:34:32 -04:00
|
|
|
catch (std::exception&)
|
2023-01-20 17:25:47 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndTable();
|
2023-01-21 22:49:35 +01:00
|
|
|
ImGui::EndTabItem();
|
2023-01-20 17:25:47 +01:00
|
|
|
}
|
2023-01-21 22:49:35 +01:00
|
|
|
ImGui::EndTabBar();
|
2023-01-20 17:25:47 +01:00
|
|
|
pkt_history_mtx.unlock();
|
|
|
|
|
|
|
|
|
|
ImGui::End();
|
|
|
|
|
}
|
2023-01-18 23:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string STDCParserModule::getID()
|
|
|
|
|
{
|
|
|
|
|
return "inmarsat_stdc_parser";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> STDCParserModule::getParameters()
|
|
|
|
|
{
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<ProcessingModule> STDCParserModule::getInstance(std::string input_file, std::string output_file_hint, nlohmann::json parameters)
|
|
|
|
|
{
|
|
|
|
|
return std::make_shared<STDCParserModule>(input_file, output_file_hint, parameters);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|