working on separating data by laps
This commit is contained in:
BIN
data/Circuit.duckdb
Normal file
BIN
data/Circuit.duckdb
Normal file
Binary file not shown.
38
src/lapinfo.c
Normal file
38
src/lapinfo.c
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
BOOL,
|
||||||
|
INT,
|
||||||
|
FLOAT,
|
||||||
|
DOUBLE,
|
||||||
|
} TelemetryDataType;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
TelemetryDataType type;
|
||||||
|
int8_t frequency;
|
||||||
|
void *data;
|
||||||
|
} TelemetryInfo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int lap_number;
|
||||||
|
double start_time;
|
||||||
|
TelemetryInfo throttle_pos;
|
||||||
|
TelemetryInfo brake_pos;
|
||||||
|
TelemetryInfo steering_pos;
|
||||||
|
TelemetryInfo speed;
|
||||||
|
} LapInfo;
|
||||||
|
|
||||||
|
void free_telemetry_info(TelemetryInfo *t) {
|
||||||
|
free(t->data);
|
||||||
|
// free(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dont use for now
|
||||||
|
void destroyLapinfo(LapInfo *info) {
|
||||||
|
free_telemetry_info(&info->throttle_pos);
|
||||||
|
free_telemetry_info(&info->brake_pos);
|
||||||
|
free_telemetry_info(&info->steering_pos);
|
||||||
|
free_telemetry_info(&info->speed);
|
||||||
|
free(info);
|
||||||
|
}
|
||||||
29
src/main.c
29
src/main.c
@@ -1,4 +1,5 @@
|
|||||||
#include <duckdb.h>
|
#include <duckdb.h>
|
||||||
|
#include <math.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -89,8 +90,7 @@ int main(int argc, char **argv) {
|
|||||||
"Wind Speed",
|
"Wind Speed",
|
||||||
"Yaw Rate"};
|
"Yaw Rate"};
|
||||||
|
|
||||||
const int channel_table_count =
|
const int channel_table_count = sizeof(channel_tables) / sizeof(channel_tables[0]);
|
||||||
sizeof(channel_tables) / sizeof(channel_tables[0]);
|
|
||||||
|
|
||||||
const char *event_tables[] = {"ABS",
|
const char *event_tables[] = {"ABS",
|
||||||
"ABSLevel",
|
"ABSLevel",
|
||||||
@@ -135,15 +135,21 @@ int main(int argc, char **argv) {
|
|||||||
"WheelsDetached",
|
"WheelsDetached",
|
||||||
"Yellow Flag State"};
|
"Yellow Flag State"};
|
||||||
|
|
||||||
const int event_table_count =
|
const int event_table_count = sizeof(event_tables) / sizeof(event_tables[0]);
|
||||||
sizeof(event_tables) / sizeof(event_tables[0]);
|
|
||||||
|
|
||||||
// Test query
|
// Test query
|
||||||
duckdb_result result;
|
duckdb_result result;
|
||||||
duckdb_query(conn, "SELECT * from \"Ambient Temperature\";\n", &result);
|
|
||||||
int32_t iterations = 0;
|
int32_t iterations = 0;
|
||||||
int32_t number_of_data_points = 0;
|
int32_t number_of_data_points = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < 1 /*channel_table_count*/; i++) {
|
||||||
|
char queryBuffer[256]; // buffer to hold the formatted query
|
||||||
|
|
||||||
|
// snprintf(queryBuffer, sizeof(queryBuffer), "SELECT * FROM \"%s\"\n", channel_tables[i]);
|
||||||
|
|
||||||
|
// duckdb_query(conn, queryBuffer, &result);
|
||||||
|
duckdb_query(conn, "SELECT CAST(value AS FLOAT) from \"Lap Time\"\n", &result);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
iterations++;
|
iterations++;
|
||||||
|
|
||||||
@@ -152,14 +158,12 @@ int main(int argc, char **argv) {
|
|||||||
if (!data_chunk) {
|
if (!data_chunk) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
idx_t row_count = duckdb_data_chunk_get_size(data_chunk); // number of rows from the data chunk
|
||||||
idx_t row_count = duckdb_data_chunk_get_size(
|
|
||||||
data_chunk); // number of rows from the data chunk
|
|
||||||
number_of_data_points += row_count;
|
number_of_data_points += row_count;
|
||||||
|
|
||||||
// first column
|
// set column
|
||||||
duckdb_vector col1 = duckdb_data_chunk_get_vector(data_chunk, 0);
|
duckdb_vector col1 = duckdb_data_chunk_get_vector(data_chunk, 0);
|
||||||
float *col1_data = (float *)duckdb_vector_get_data(col1);
|
float_t *col1_data = (float_t *)duckdb_vector_get_data(col1);
|
||||||
uint64_t *col1_validity = duckdb_vector_get_validity(col1);
|
uint64_t *col1_validity = duckdb_vector_get_validity(col1);
|
||||||
|
|
||||||
for (idx_t row = 0; row < row_count; row++) {
|
for (idx_t row = 0; row < row_count; row++) {
|
||||||
@@ -172,9 +176,10 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
duckdb_destroy_data_chunk(&data_chunk);
|
duckdb_destroy_data_chunk(&data_chunk);
|
||||||
}
|
}
|
||||||
|
duckdb_destroy_result(&result);
|
||||||
|
}
|
||||||
|
|
||||||
printf("\nNumber of iterations: %d, number of data points: %d\n",
|
printf("\nNumber of iterations: %d, number of data points: %d\n", iterations, number_of_data_points);
|
||||||
iterations, number_of_data_points);
|
|
||||||
|
|
||||||
printf("Shutting down HardCompound!\n");
|
printf("Shutting down HardCompound!\n");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user