[16] | 1 | // |
---|
| 2 | // |
---|
| 3 | // |
---|
| 4 | |
---|
| 5 | #include <stdio.h> |
---|
| 6 | #include "cbr.h" |
---|
| 7 | |
---|
| 8 | int main() { |
---|
[28] | 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[] = { |
---|
[16] | 27 | "BER", "throughput", |
---|
| 28 | "mod_scheme", "tx_power", |
---|
| 29 | "noise_power", "path_loss", |
---|
| 30 | "utility" |
---|
[28] | 31 | };*/ |
---|
| 32 | |
---|
| 33 | for (i = 0; i<num_cols; i++){ |
---|
| 34 | printf(" %s",cols[i]); |
---|
| 35 | } |
---|
| 36 | printf("\n"); |
---|
| 37 | |
---|
[16] | 38 | float vals[num_cols]; |
---|
[20] | 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 |
---|
[16] | 46 | int rc; |
---|
| 47 | |
---|
[18] | 48 | // create cbr database/table |
---|
[16] | 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 | |
---|
[20] | 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 | |
---|
[16] | 65 | // clean up |
---|
| 66 | cbr_free(mycbr); |
---|
| 67 | |
---|
| 68 | printf("done.\n"); |
---|
| 69 | return 0; |
---|
| 70 | } |
---|
| 71 | |
---|