#ifndef MCRLCONTROLLER_RTLF_H #define MCRLCONTROLLER_RTLF_H #include #include #include #define RTLF_MAGIC_NUMBER "RTLF" #define RTLF_VERSION 1 #define RTLF_RECORD_SIZE 80 // 10 x float64 = 80 bytes #pragma pack(push, 1) // Fixed part of the Header Block (16 bytes) typedef struct { char magic_number[4]; // 0-4: 'RTLF' __uint32_t version; // 4-8: File format version (Must be 1) __uint32_t car_id; // 8-12: Unique numerical ID __uint32_t track_name_len;// 12-16: Length of the Track Name string that follows } RTLF_Header_Fixed; // Single Data Record (80 bytes) typedef struct { double timestamp; // 0-8: Time (seconds) double gps_long; // 8-16: Position X (meters) double gps_lat; // 16-24: Position Y (meters) double facing_x; // 24-32: X-component of the car's orientation double facing_y; // 32-40: Y-component of the car's orientation double facing_z; // 40-48: Z-component of the car's orientation double acceleration_x; // 48-56: Acceleration X (m/s^2) double acceleration_y; // 56-64: Acceleration Y (m/s^2) double acceleration_z; // 64-72: Acceleration Z (m/s^2) double speed; // 72-80: Speed (m/s) } RTLF_Data_Record; #pragma pack(pop) typedef struct { FILE* file; RTLF_Header_Fixed header; char* track_name; long data_start_offset; } RTLF_Context; RTLF_Context* rtlf_open_write(const char* filename, __uint32_t car_id, const char* track_name); int rtlf_write_record(RTLF_Context* ctx, const RTLF_Data_Record* record); void rtlf_close(RTLF_Context* ctx); #endif //MCRLCONTROLLER_RTLF_H