charts...
git-svn-id: file:///home/jan/tmp/wetterstation/trunk@82 dd492736-c11a-0410-ad51-8c26713eaf7f
This commit is contained in:
parent
329ed6e6b4
commit
033104310c
|
|
@ -24,22 +24,22 @@ static char *get_type_table_by_id(PGconn *, int );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Holt eine Liste mit den Werten und den jeweiligen x-koordinaten */
|
||||||
pix_list_ptr get_pix_list(int c_width){
|
pix_list_ptr get_pix_list(int c_width){
|
||||||
double seconds_per_pix = ((double)c_width)/((double)img_cfg.show_interval);
|
double seconds_per_pix = ((double)c_width)/((double)img_cfg.show_interval); /* Pixel pro Sekunde */
|
||||||
char *conn_string = get_conn_string();
|
char *conn_string = get_conn_string(); /* Verbindungs-String */
|
||||||
PGconn *conn = pg_check_connect(conn_string);
|
PGconn *conn = pg_check_connect(conn_string); /* Datenbank - Verbindung */
|
||||||
char *table = get_type_table_by_id(conn, img_cfg.sens_id);
|
char *table = get_type_table_by_id(conn, img_cfg.sens_id); /* Tabellen - Name */
|
||||||
char *query = malloc(sizeof(char)*BUFFSIZE);
|
char *query = malloc(sizeof(char)*BUFFSIZE); /* Query */
|
||||||
PGresult *res = NULL;
|
PGresult *res = NULL; /* Darenbank - Result */
|
||||||
int time_field;
|
int time_field; /* Id ses Timestamp-Feldes */
|
||||||
int val_field;
|
int val_field; /* Id des Wert - Feldes */
|
||||||
long time_temp;
|
long time_temp; /* Hilfsvariable */
|
||||||
int pix_coord;
|
int pix_coord; /* x - Koordinate, an die der Wert gehört */
|
||||||
int i;
|
int i; /* Laufvariable zum durchlaufen des Datenbank-resuls */
|
||||||
long base_time;
|
long base_time; /* Zeit an der 0-Koordinate (lt. Datenbank!) */
|
||||||
pix_list_ptr list_ptr = NULL;
|
pix_list_ptr list_ptr = NULL; /* Zeiger auf den Anfang der Wertliste */
|
||||||
pix_list_ptr temp_ptr = NULL;
|
pix_list_ptr temp_ptr = NULL; /* Zeiger zum durchlaufen der Wertliste */
|
||||||
|
|
||||||
DEBUGOUT1("\nHole Daten...\n");
|
DEBUGOUT1("\nHole Daten...\n");
|
||||||
DEBUGOUT2(" Ein Pixel entspricht %f sekunden\n", seconds_per_pix);
|
DEBUGOUT2(" Ein Pixel entspricht %f sekunden\n", seconds_per_pix);
|
||||||
|
|
@ -73,6 +73,7 @@ pix_list_ptr get_pix_list(int c_width){
|
||||||
return list_ptr;
|
return list_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Speichert einen geholten Wert ab */
|
||||||
static pix_list_ptr add_pix_value(pix_list_ptr ptr, int coord, int value){
|
static pix_list_ptr add_pix_value(pix_list_ptr ptr, int coord, int value){
|
||||||
|
|
||||||
if(ptr == NULL){
|
if(ptr == NULL){
|
||||||
|
|
@ -88,6 +89,7 @@ static pix_list_ptr add_pix_value(pix_list_ptr ptr, int coord, int value){
|
||||||
if(coord == ptr->x_pix_coord){
|
if(coord == ptr->x_pix_coord){
|
||||||
ptr->value_sum += value;
|
ptr->value_sum += value;
|
||||||
ptr->value_count++;
|
ptr->value_count++;
|
||||||
|
|
||||||
DEBUGOUT5(" Zu x-pos. %d %d. Wert (%d) hinzugefügt. Durchschn.: %d\n", ptr->x_pix_coord, ptr->value_count, value, (ptr->value_sum/ptr->value_count) );
|
DEBUGOUT5(" Zu x-pos. %d %d. Wert (%d) hinzugefügt. Durchschn.: %d\n", ptr->x_pix_coord, ptr->value_count, value, (ptr->value_sum/ptr->value_count) );
|
||||||
} else {
|
} else {
|
||||||
ptr->next = malloc(sizeof(pix_list_t));
|
ptr->next = malloc(sizeof(pix_list_t));
|
||||||
|
|
@ -96,6 +98,7 @@ static pix_list_ptr add_pix_value(pix_list_ptr ptr, int coord, int value){
|
||||||
ptr->value_sum = value;
|
ptr->value_sum = value;
|
||||||
ptr->value_count = 1;
|
ptr->value_count = 1;
|
||||||
ptr->next = NULL;
|
ptr->next = NULL;
|
||||||
|
|
||||||
DEBUGOUT3(" An x-pos. %d Wert %d eingefuegt\n", ptr->x_pix_coord, ptr->value_sum);
|
DEBUGOUT3(" An x-pos. %d Wert %d eingefuegt\n", ptr->x_pix_coord, ptr->value_sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue