root/vtcross/trunk/src/main_cbr.c @ 28

Revision 28, 1.6 KB (checked in by ahe, 16 years ago)

incorporate ezxml with cbr

Line 
1//
2//
3//
4
5#include <stdio.h>
6#include "cbr.h"
7
8int main() {
9    unsigned int num_cols = 7;
10    unsigned int i;
11
12    ezxml_t f1 = ezxml_parse_file("another.xml"), engine, column;
13    char * cols[num_cols];
14   
15    for (engine = ezxml_child(f1, "engine"); engine; engine = engine->next){
16        i = 0;
17        for (column = ezxml_child(engine, "column"); column; column = column->next){
18            cols[i] = ezxml_child(column, "name")->txt;
19            i++;
20        }
21    }
22
23
24    free(f1);
25                           
26    /* char * cols[] = {
27        "BER", "throughput",
28        "mod_scheme", "tx_power",
29        "noise_power", "path_loss",
30        "utility"
31    };*/
32   
33    for (i = 0; i<num_cols; i++){
34        printf(" %s",cols[i]);
35    }
36    printf("\n");
37
38    float vals[num_cols];
39    vals[0] = 1e-3f;    // BER
40    vals[1] = 10e3f;    // throughput
41    vals[2] = 1;        // mod_scheme
42    vals[3] = -3.0f;    // tx_power
43    vals[4] = -50.0f;   // noise_power
44    vals[5] = 125.0f;   // path_loss
45    vals[6] = 0.762;    // utility
46    int rc;
47
48    // create cbr database/table
49    cbr mycbr = cbr_create("ex1", "data", cols, num_cols);
50
51    // add row here
52    rc = cbr_add_row(mycbr, cols, vals, num_cols);
53
54    // print
55    cbr_print(mycbr);
56
57    // simple search: find entry where...
58    //   BER < 1e-2 and path_loss > 100
59    char * search_names[] = {"BER", "path_loss"};
60    int search_ops[] = {LT, GT};
61    float search_vals[] = {1e-2f, 100.f};
62    float retvals[num_cols];
63    rc = cbr_search(mycbr, search_names, search_ops, search_vals, 2, retvals);
64
65    // clean up
66    cbr_free(mycbr);
67
68    printf("done.\n");
69    return 0;
70}
71
Note: See TracBrowser for help on using the browser.