diff --git a/common/utils/T/tracer/logger/Makefile b/common/utils/T/tracer/logger/Makefile index 8d23717a1329ba42cd5a156e47df673246ef13c3..92431739dba89d44104bc8c509daec7ea479af2b 100644 --- a/common/utils/T/tracer/logger/Makefile +++ b/common/utils/T/tracer/logger/Makefile @@ -1,7 +1,8 @@ CC=gcc CFLAGS=-Wall -g -pthread -I.. -OBJS=logger.o textlog.o framelog.o ttilog.o timelog.o ticklog.o iqlog.o +OBJS=logger.o textlog.o framelog.o ttilog.o timelog.o ticklog.o iqlog.o \ + iqdotlog.o logger.a: $(OBJS) ar cr logger.a $(OBJS) diff --git a/common/utils/T/tracer/logger/iqdotlog.c b/common/utils/T/tracer/logger/iqdotlog.c new file mode 100644 index 0000000000000000000000000000000000000000..f635f9718ddd9fac158dd43ac51b11ada8d79d4b --- /dev/null +++ b/common/utils/T/tracer/logger/iqdotlog.c @@ -0,0 +1,82 @@ +#include "logger.h" +#include "logger_defs.h" +#include "handler.h" +#include "database.h" +#include "filter/filter.h" +#include <stdlib.h> +#include <string.h> +#include <stdio.h> + +struct iqdotlog { + struct logger common; + void *database; + int i_arg; + int q_arg; +}; + +static void _event(void *p, event e) +{ + struct iqdotlog *l = p; + int i; + float I, Q; + + if (l->common.filter != NULL && filter_eval(l->common.filter, e) == 0) + return; + + I = e.e[l->i_arg].i; + Q = e.e[l->q_arg].i; + + for (i = 0; i < l->common.vsize; i++) + l->common.v[i]->append(l->common.v[i], &I, &Q, 1); +} + +logger *new_iqdotlog(event_handler *h, void *database, + char *event_name, char *I, char *Q) +{ + struct iqdotlog *ret; + int event_id; + database_event_format f; + int i; + + ret = calloc(1, sizeof(struct iqdotlog)); if (ret == NULL) abort(); + + ret->common.event_name = strdup(event_name); + if (ret->common.event_name == NULL) abort(); + ret->database = database; + + event_id = event_id_from_name(database, event_name); + + ret->common.handler_id = register_handler_function(h,event_id,_event,ret); + + f = get_format(database, event_id); + + /* look for args */ + ret->i_arg = -1; + ret->q_arg = -1; + for (i = 0; i < f.count; i++) { + if (!strcmp(f.name[i], I)) ret->i_arg = i; + if (!strcmp(f.name[i], Q)) ret->q_arg = i; + } + if (ret->i_arg == -1) { + printf("%s:%d: argument '%s' not found in event '%s'\n", + __FILE__, __LINE__, I, event_name); + abort(); + } + if (ret->q_arg == -1) { + printf("%s:%d: argument '%s' not found in event '%s'\n", + __FILE__, __LINE__, Q, event_name); + abort(); + } + if (strcmp(f.type[ret->i_arg], "int") != 0) { + printf("%s:%d: argument '%s' has wrong type (should be 'int')\n", + __FILE__, __LINE__, I); + abort(); + } + if (strcmp(f.type[ret->q_arg], "int") != 0) { + printf("%s:%d: argument '%s' has wrong type (should be 'int')\n", + __FILE__, __LINE__, Q); + abort(); + } + + return ret; +} diff --git a/common/utils/T/tracer/logger/logger.h b/common/utils/T/tracer/logger/logger.h index a777581db91e513509a5abb0ebed9cfa359cc4e5..b2ab4f8cbcd09367d30ffa74a0d16891f83b4264 100644 --- a/common/utils/T/tracer/logger/logger.h +++ b/common/utils/T/tracer/logger/logger.h @@ -16,6 +16,8 @@ logger *new_ticklog(void *event_handler, void *database, logger *new_iqlog(void *event_handler, void *database, char *event_name, char *nb_rb, char *N_RB_UL, char *symbols_per_tti, char *buffer_varname); +logger *new_iqdotlog(void *event_handler, void *database, + char *event_name, char *I, char *Q); void framelog_set_skip(logger *_this, int skip_delay); void framelog_set_update_only_at_sf9(logger *_this, int update_only_at_sf9);