Working on charts

git-svn-id: file:///home/jan/tmp/wetterstation/trunk@78 dd492736-c11a-0410-ad51-8c26713eaf7f
This commit is contained in:
losinshi 2006-09-12 13:55:49 +00:00
parent 572b1c3271
commit 25d6a8c7a7
6 changed files with 47 additions and 16 deletions

View File

@ -6,7 +6,7 @@ LDFLAS = -o
#INCL = -I$$(pg_config --includedir)
BIN_NAME = chart
OBJS = chart.o config.o common.o image_file/image_file.o image_file/image_config.o
OBJS = chart.o config.o common.o image_file/image_file.o image_file/image_config.o image_file/image_draw.o image_file/image_common.o image_file/image_data.o
CONF_NAME = chart.conf
@ -43,13 +43,26 @@ config.o: config.c \
common.h
image_file/image_config.o: image_file/image_config.c \
common.h \
definitions.h \
config.h \
image_file/image_common.h
image_file/image_data.o: image_file/image_data.c \
image_file/image_data.h \
image_file/image_common.h \
config.h
common.h \
definitions.h
image_file/image_draw.o: image_file/image_draw.c \
image_file/image_draw.h \
image_file/image_data.h
image_file/image_file.o: image_file/image_file.c \
definitions.h \
common.h \
image_file/image_common.h \
image_file/image_file.h \
image_file/image_config.h
image_file/image_config.h \
image_file/image_draw.h
image_file/image_common.o: image_file/image_common.c \
image_file/image_common.h
# Compillieren
$(OBJS):

View File

@ -1,6 +1,7 @@
typedef struct image_cfg_t {
char *file_name;
char *headline;
char *table_field;
long gen_interval;
long show_interval;
long label_interval;

View File

@ -38,6 +38,7 @@ static const config_keyword keywords[] = {
/* keyword handler variable address default */
{"filename", read_str, &(img_cfg.file_name), ""},
{"headline", read_str, &(img_cfg.headline), ""},
{"table_field", read_str, &(img_cfg.table_field), ""},
{"gen_interval", read_time, &(img_cfg.gen_interval), ""},
{"show_interval", read_time, &(img_cfg.show_interval), ""},
{"label_interval", read_time, &(img_cfg.label_interval), ""},
@ -104,7 +105,7 @@ int get_image_cfg(char *file){
buff = strcpy(buff, global_opts.image_cfg_location);
buff = strcat(buff, file);
DEBUGOUT2("Lese Config-File: '%s' \n", buff);
DEBUGOUT2("\nLese Config-File: '%s' \n", buff);
ret_var = read_config(buff, 1, keywords);
return ret_var;

View File

@ -12,14 +12,6 @@
#define BUFFSIZE_EXTRA 2048
typedef struct pix_list *pix_list_ptr;
typedef struct pix_list {
pix_list_ptr next;
int x_pix_coord;
int value_count;
int value_sum;
} pix_list_t;
static char *get_conn_string();
@ -34,8 +26,14 @@ static char *get_type_table_by_id(PGconn *, int );
pix_list_ptr get_pix_list(int c_width){
double seconds_per_pix = (img_cfg.show_interval * 0.1)/(c_width * 0.1);
PGconn *connection = pg_check_connect(get_conn_string());
char *conn_string = get_conn_string();
PGconn *conn = pg_check_connect(conn_string);
PQfinish(conn);
free(conn_string);
return NULL;
}
/* baut den String fuer die Postgres-Verbindung zusammen */

View File

@ -29,11 +29,18 @@
#include "image_common.h"
#include "image_file.h"
#include "image_config.h"
#include "image_draw.h"
/* Optionen des Bildes */
image_cfg img_cfg;
static void regenerate_image();
static int check_file_interval();
/* Handelt ein Bild */
void process_image_cfg(char *image_cfg_file){
@ -49,18 +56,21 @@ void process_image_cfg(char *image_cfg_file){
DEBUGOUT2("Width = %d\n", img_cfg.width);
DEBUGOUT2("Height = %d\n", img_cfg.height);
DEBUGOUT2("SensorId = %d\n", img_cfg.sens_id);
DEBUGOUT2("TabellenFeld = %s\n", img_cfg.table_field);
DEBUGOUT1("\n");
} else {
return;
}
check_file_interval();
if(check_file_interval()){
}
sleep(3);
}
/* Checkt ob es wieder an der Zeit ist ein File
* neu zu erstellen */
int check_file_interval(){
static int check_file_interval(){
struct stat stat_buff;
time_t now;
@ -68,6 +78,7 @@ int check_file_interval(){
if(access(img_cfg.file_name, F_OK) == -1){
DEBUGOUT2("Datei '%s' existiert nicht\n", img_cfg.file_name);
DEBUGOUT1("Sie muss neu generiert werden!\n");
return 1;
}
if ((stat(img_cfg.file_name, &stat_buff)) != -1){
@ -76,8 +87,10 @@ int check_file_interval(){
diff_sek = difftime(now, stat_buff.st_mtime);
DEBUGOUT3("Datei '%s' ist %d Sek. alt \n", img_cfg.file_name, diff_sek);
DEBUGOUT2("Sie soll aller %d Sek. neu generiert werden \n", img_cfg.gen_interval);
if(diff_sek > (img_cfg.gen_interval * 60))
if(diff_sek > img_cfg.gen_interval)
DEBUGOUT1("Sie muss neu generiert werden!\n");
return 1;
} else {
@ -85,3 +98,7 @@ int check_file_interval(){
}
return 0;
}
static void regenerate_image(){
draw_to_file(NULL);
}

View File

@ -1,5 +1,6 @@
filename /home/jan/Testbild.png
headline Testbild
table_field temp
gen_interval 15m
show_interval 1h
label_interval 10m