From bace2d7f20acc609d552a80bb018939d5e8afab8 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Mon, 25 May 2026 21:36:50 +0200 Subject: Save file compression and data aggregation always enabled --- data/client.cpp | 24 +++++++++++++----------- data/server.c | 24 ++++++++++++------------ 2 files changed, 25 insertions(+), 23 deletions(-) (limited to 'data') diff --git a/data/client.cpp b/data/client.cpp index 2a162f2..65494b0 100644 --- a/data/client.cpp +++ b/data/client.cpp @@ -4,12 +4,14 @@ #include #include #include -#include #include #include #include #include #include + +#include + #include "logger.c" #define FETCH_INTERVAL 10 @@ -185,7 +187,7 @@ void data_fetch(void) { json_object_object_add(request, "x-current", json_object_new_int(g_x_current)); const char *request_str = json_object_to_json_string(request); - g_info("Sending request to server: %s", request_str); + log_info("Sending request to server: %s", request_str); int socket_fd = socket(AF_INET, SOCK_STREAM, 0); struct sockaddr_in socket_addr; memset(&socket_addr, 0, sizeof(struct sockaddr_in)); @@ -198,7 +200,7 @@ void data_fetch(void) { struct json_object *response = json_object_from_fd(socket_fd); const char *response_str = json_object_to_json_string(response); - g_info("Server responded with: %s", response_str); + log_info("Server responded with: %s", response_str); json_object_put(request); json_object_put(response); @@ -223,14 +225,14 @@ int data_fetching_thread(void *data) { } void data_start_fetching(void) { - g_info("Starting data fetching thread"); + log_info("Starting data fetching thread"); g_status = STATUS_RUNNING; thrd_create(&g_data_fetching_thread, (thrd_start_t)data_fetching_thread, nullptr); } void data_stop_fetching(void) { assert(g_status == STATUS_RUNNING); - g_info("Stopping data fetching thread"); + log_info("Stopping data fetching thread"); g_status = STATUS_STOPPING; thrd_join(g_data_fetching_thread, nullptr); } @@ -410,13 +412,13 @@ void gui_print(void) { void sig_handler(int signo) { (void)signo; - g_warn("Signal received, will stop SALIS data client..."); + log_warn("Signal received, will stop SALIS data client..."); if (g_status == STATUS_RUNNING) data_stop_fetching(); glfwSetWindowShouldClose(g_window, GLFW_TRUE); } void glfw_error_callback(int error, const char* description) { - g_warn("GLFW error %d: %s", error, description); + log_warn("GLFW error %d: %s", error, description); } void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { @@ -504,9 +506,9 @@ int main(int argc, char **argv) { signal(SIGINT, sig_handler); signal(SIGTERM, sig_handler); - g_info("Starting SALIS data client"); + log_info("Starting SALIS data client"); - g_info("Initializing GLFW"); + log_info("Initializing GLFW"); glfwSetErrorCallback(glfw_error_callback); glfwInitHint(GLFW_WAYLAND_LIBDECOR, GLFW_WAYLAND_DISABLE_LIBDECOR); if (!glfwInit()) assert(false); @@ -518,7 +520,7 @@ int main(int argc, char **argv) { glfwMakeContextCurrent(g_window); glfwSwapInterval(1); // enable vsync - g_info("Initializing ImGui"); + log_info("Initializing ImGui"); IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImPlot::CreateContext(); @@ -567,7 +569,7 @@ int main(int argc, char **argv) { ImPlot::DestroyContext(); ImGui::DestroyContext(); - g_info("Stopping SALIS data client"); + log_info("Stopping SALIS data client"); glfwDestroyWindow(g_window); glfwTerminate(); return 0; diff --git a/data/server.c b/data/server.c index 4574415..8581b83 100644 --- a/data/server.c +++ b/data/server.c @@ -24,13 +24,13 @@ struct Socket { // ---------------------------------------------------------------------------- void sig_handler(int signo) { (void)signo; - g_warn("Signal received, will stop SALIS data server"); + log_warn("Signal received, will stop SALIS data server"); sql_close(); exit(0); } void respond_name(int socket_fd) { - g_info("Client requested simulation name"); + log_info("Client requested simulation name"); struct json_object *sim_name = json_object_new_object(); json_object_object_add(sim_name, "name", json_object_new_string(NAME)); @@ -39,7 +39,7 @@ void respond_name(int socket_fd) { } void respond_opts(int socket_fd) { - g_info("Client requested simulation options"); + log_info("Client requested simulation options"); struct json_object *sim_opts = json_object_from_file(SIM_OPTS); json_object_to_fd(socket_fd, sim_opts, 0); @@ -47,7 +47,7 @@ void respond_opts(int socket_fd) { } void respond_hash(int socket_fd) { - g_info("Client requested git hash"); + log_info("Client requested git hash"); char buff[41] = { 0 }; FILE *pipe = popen("git rev-parse HEAD", "r"); @@ -64,12 +64,12 @@ void respond_data(int socket_fd, struct json_object *request) { assert(request); const char *request_str = json_object_to_json_string(request); - g_info("Client requested simulation data with the following parameters: %s", request_str); + log_info("Client requested simulation data with the following parameters: %s", request_str); struct json_object *response = json_object_new_object(); json_object_object_add(response, "response", json_object_new_string("hello!")); const char *response_str = json_object_to_json_string(response); - g_info("Sending response to client: %s", response_str); + log_info("Sending response to client: %s", response_str); json_object_to_fd(socket_fd, response, 0); shutdown(socket_fd, SHUT_WR); @@ -81,7 +81,7 @@ int handle_client(struct Socket *socket) { char socket_ip[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &socket->addr.sin_addr, socket_ip, INET_ADDRSTRLEN); - g_info("Client connected: %s:%d", socket_ip, ntohs(socket->addr.sin_port)); + log_info("Client connected: %s:%d", socket_ip, ntohs(socket->addr.sin_port)); struct json_object *request_json = json_object_from_fd(socket->fd); struct json_object *request_str = NULL; @@ -105,7 +105,7 @@ int handle_client(struct Socket *socket) { json_object_put(request_json); - g_info("Client disconnected: %s:%d", socket_ip, ntohs(socket->addr.sin_port)); + log_info("Client disconnected: %s:%d", socket_ip, ntohs(socket->addr.sin_port)); close(socket->fd); free(socket); @@ -113,14 +113,14 @@ int handle_client(struct Socket *socket) { } int main(void) { - g_info("Initializing salis data server"); - g_info("Connecting to database in: %s", DATA_PUSH_PATH); + log_info("Initializing salis data server"); + log_info("Connecting to database in: %s", DATA_PUSH_PATH); sql_open(); signal(SIGINT, sig_handler); signal(SIGTERM, sig_handler); - g_info("Binding to port: %d", PORT); + log_info("Binding to port: %d", PORT); int opt = 1; int socket_fd = socket(AF_INET, SOCK_STREAM, 0); setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); @@ -130,7 +130,7 @@ int main(void) { socket_addr.sin_port = htons(PORT); bind(socket_fd, (struct sockaddr *)&socket_addr, sizeof(struct sockaddr_in)); - g_info("Listening..."); + log_info("Listening..."); listen(socket_fd, BACKLOG); while (true) { -- cgit v1.3