From 0bb9f01fc4170652ad7f3227880b4fb07e5fe1e4 Mon Sep 17 00:00:00 2001 From: losinshi Date: Wed, 13 Sep 2006 12:44:02 +0000 Subject: [PATCH] Working on charts git-svn-id: file:///home/jan/tmp/wetterstation/trunk@85 dd492736-c11a-0410-ad51-8c26713eaf7f --- cronjob/chart/Makefile | 2 +- cronjob/chart/chart.conf | 3 ++- cronjob/chart/image_file/image_common.h | 16 ++++++++++++---- cronjob/chart/image_file/image_config.c | 25 ++++++++++++++++++++++++- cronjob/chart/image_file/image_draw.c | 9 ++++++++- cronjob/chart/image_file/image_file.c | 4 ++-- cronjob/chart/image_file/testimage.conf | 4 +++- 7 files changed, 52 insertions(+), 11 deletions(-) diff --git a/cronjob/chart/Makefile b/cronjob/chart/Makefile index 0647951..5d24c32 100644 --- a/cronjob/chart/Makefile +++ b/cronjob/chart/Makefile @@ -25,7 +25,7 @@ all: $(BIN_NAME) # Binary Linken $(BIN_NAME): $(OBJS) @ echo Linke: $(LD) $(DEBUG) $(NOLOG) -L$$(pg_config --libdir)/pgsql -lm -lpq $(LDFLAS) $(BIN_NAME) $(OBJS) - @ $(LD) $(DEBUG) $(NOLOG) -L$$(pg_config --libdir)/pgsql -lm -lpq $(LDFLAS) $(BIN_NAME) $(OBJS) + @ $(LD) $(DEBUG) $(NOLOG) -L$$(pg_config --libdir)/pgsql -lefence -lm -lpq $(LDFLAS) $(BIN_NAME) $(OBJS) @ echo Binary $(BIN_NAME) ist fertig! # Abhängigkeiten diff --git a/cronjob/chart/chart.conf b/cronjob/chart/chart.conf index 0fbd4dd..596ac8a 100644 --- a/cronjob/chart/chart.conf +++ b/cronjob/chart/chart.conf @@ -1,4 +1,5 @@ -fork yes +#fork yes +fork no image_cfg_location image_file/ image_cfg testimage.conf diff --git a/cronjob/chart/image_file/image_common.h b/cronjob/chart/image_file/image_common.h index e34ddb1..9825405 100644 --- a/cronjob/chart/image_file/image_common.h +++ b/cronjob/chart/image_file/image_common.h @@ -1,4 +1,12 @@ -typedef struct image_cfg_t { +typedef struct img_color *img_color_ptr; +typedef struct img_color { + int r; + int g; + int b; + int alpha; +} img_color_t; + +typedef struct image_cfg { char *file_name; char *headline; char *table_field; @@ -11,7 +19,7 @@ typedef struct image_cfg_t { int width; int height; int sens_id; -} image_cfg; + img_color_ptr bg_color; +} image_cfg_t; - -extern image_cfg img_cfg; +extern image_cfg_t img_cfg; diff --git a/cronjob/chart/image_file/image_config.c b/cronjob/chart/image_file/image_config.c index 12d743e..e64e5c4 100644 --- a/cronjob/chart/image_file/image_config.c +++ b/cronjob/chart/image_file/image_config.c @@ -28,7 +28,7 @@ #include "image_common.h" static int read_time(const char *, void *); - +static int read_color(const char *, void *); @@ -49,11 +49,34 @@ static const config_keyword keywords[] = { {"height", read_int, &(img_cfg.height), ""}, {"sensor_id", read_int, &(img_cfg.sens_id), ""}, + + {"bg_color", read_color, &(img_cfg.bg_color), ""}, + {"", NULL, NULL, ""} }; +static int read_color(const char *line, void *arg){ + img_color_ptr *col = arg; + img_color_ptr tmp = NULL; + char *buff = malloc(sizeof(char)*3); + + if(strlen(line) == 11){ + if (strchr(line, ':') != NULL){ + tmp = malloc(sizeof(img_color_t)); + tmp->r = strtol(strncpy(buff, line, 2), NULL, 16); + tmp->b = strtol(strncpy(buff, line+3, 2), NULL, 16); + tmp->g = strtol(strncpy(buff, line+6, 2), NULL, 16); + tmp->alpha = strtol(strncpy(buff, line+9, 2), NULL, 16); + + DEBUGOUT5(" Farbe gelesen: rot:%2x gelb:%2x gruen:%2x mit alpha:%2x\n", tmp->r, tmp->b, tmp->g, tmp->alpha) ; + } + } + + *col = tmp; + +} /* Ein Interval einlesen. * wandelt Zeitangaben von der Form: diff --git a/cronjob/chart/image_file/image_draw.c b/cronjob/chart/image_file/image_draw.c index b6bbbca..a2e614d 100644 --- a/cronjob/chart/image_file/image_draw.c +++ b/cronjob/chart/image_file/image_draw.c @@ -2,8 +2,14 @@ #include "image_draw.h" #include "image_data.h" + +static void create_image(); +static void draw_image(); +static void write_image(); + + int draw_to_file(FILE *fd){ - get_pix_list(210); + draw_image(); } static void create_image(){ @@ -11,6 +17,7 @@ static void create_image(){ } static void draw_image(){ + pix_list_ptr pix_list = get_pix_list(300); } diff --git a/cronjob/chart/image_file/image_file.c b/cronjob/chart/image_file/image_file.c index eae198a..845ddf3 100644 --- a/cronjob/chart/image_file/image_file.c +++ b/cronjob/chart/image_file/image_file.c @@ -33,7 +33,7 @@ /* Optionen des Bildes */ -image_cfg img_cfg; +image_cfg_t img_cfg; static void regenerate_image(); @@ -67,7 +67,7 @@ void process_image_cfg(char *image_cfg_file){ regenerate_image(); } -// sleep(3); + //sleep(30); } diff --git a/cronjob/chart/image_file/testimage.conf b/cronjob/chart/image_file/testimage.conf index c17b44d..fbc2fc3 100644 --- a/cronjob/chart/image_file/testimage.conf +++ b/cronjob/chart/image_file/testimage.conf @@ -4,9 +4,11 @@ manual_table no manual_table_name auss2_data table_field temp gen_interval 15m -show_interval 1y +show_interval 1h label_interval 10m label_sum no width 400 height 250 sensor_id 1 + +bg_color 10:2c:30:00 #test