Changeset 26 for vtcross/trunk
- Timestamp:
- 10/24/08 15:52:19 (16 years ago)
- Location:
- vtcross/trunk
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/Makefile
r16 r26 11 11 gcc -Wall -c src/cognitive_radio_test.c -Wall -o cognitive_radio_test.o 12 12 13 cognitive_radio_test: cognitive_radio_test.o main_test.o 14 gcc cognitive_radio_test.o main_test.o -Wall -lm-lsigprocc -o cognitive_radio_test13 cognitive_radio_test: cognitive_radio_test.o main_test.o sqlite3.o cbr.o 14 gcc cognitive_radio_test.o cbr.o sqlite3.o main_test.o -Wall -lm -ldl -pthread -lsigprocc -o cognitive_radio_test 15 15 16 16 utility.o: src/utility.c -
vtcross/trunk/src/cbr.c
r25 r26 56 56 char *zErrMsg = 0; 57 57 58 printf("command: %s\n", _cbr->command);58 //printf("command: %s\n", _cbr->command); 59 59 rc = sqlite3_exec(_cbr->db, _cbr->command, callback, 0, &zErrMsg); 60 60 if( rc!=SQLITE_OK){ … … 62 62 sqlite3_free(zErrMsg); 63 63 } else{ 64 printf("command executed.\n");64 //printf("command executed.\n"); 65 65 } 66 66 return rc; … … 74 74 unsigned int i; 75 75 76 printf("command: %s\n", _cbr->command);76 //printf("command: %s\n", _cbr->command); 77 77 sqlite3_stmt * pStatement; 78 78 rc = sqlite3_prepare_v2(_cbr->db, _cbr->command, -1, &pStatement, NULL); … … 81 81 _retvals[i] = sqlite3_column_double(pStatement, i); 82 82 } else { 83 printf("no row found\n");83 //printf("no row found\n"); 84 84 return 0; 85 85 } … … 243 243 244 244 // generate command 245 printf("%s\n", _cbr->command);245 //printf("%s\n", _cbr->command); 246 246 strcpy(_cbr->command, "insert into "); 247 247 strcat(_cbr->command, _cbr->tablename); -
vtcross/trunk/src/main_test.c
r12 r26 7 7 #include <math.h> 8 8 #include <sigprocc/sigprocc.h> 9 #include "cbr.h" 9 10 #include "cognitive_radio_test.h" 10 11 … … 36 37 md->tx_power_dBW = -3.0f; // transmit power [dBW] 37 38 md->symbol_rate = 250e3f; // symbol rate [symbols/s] 39 40 // case-based reasoner 41 unsigned int num_cols = 7; 42 char * cols[] = { 43 "BER", "throughput", 44 "mod_scheme", "tx_power", 45 "noise_power", "path_loss", 46 "utility" 47 }; 48 float vals[num_cols]; 49 vals[0] = 1e-3f; // BER 50 vals[1] = 10e3f; // throughput 51 vals[2] = 1; // mod_scheme 52 vals[3] = -3.0f; // tx_power 53 vals[4] = -50.0f; // noise_power 54 vals[5] = 125.0f; // path_loss 55 vals[6] = 0.762; // utility 56 int rc; 57 58 // create cbr database/table 59 cbr mycbr = cbr_create("ex1", "data", cols, num_cols); 60 61 // add row here 62 //rc = cbr_add_row(mycbr, cols, vals, num_cols); 63 64 // print 65 cbr_print(mycbr); 66 67 // cbr search setup 68 char * search_names[] = {"BER"}; 69 int search_ops[] = {LT}; 70 float search_vals[] = {30.0f/(float)PACKET_SIZE}; 71 float retvals[num_cols]; 72 38 73 39 74 unsigned int i; … … 76 111 // 77 112 78 // simple power adaptation 79 if (num_bit_errors > 30) { 80 md->tx_power_dBW += 0.1f; 113 // store result 114 vals[0] = (float) num_bit_errors / PACKET_SIZE; // BER 115 vals[1] = throughput_bps; 116 //vals[2] = // mod_scheme 117 vals[3] = md->tx_power_dBW; // tx_power 118 vals[6] = md->tx_power_dBW;// utility 119 120 rc = cbr_add_row(mycbr, cols, vals, num_cols); 121 122 // execute cbr search 123 rc = cbr_search(mycbr, search_names, search_ops, search_vals, 1, retvals); 124 125 if (rc==0) { 126 // no solution found 127 md->tx_power_dBW += 0.2f; 128 //printf("no solution found\n"); 81 129 } else { 82 md->tx_power_dBW -= 0.1f; 130 // set values 131 md->tx_power_dBW = retvals[3]; 83 132 } 84 133 85 134 } 86 135 136 cbr_free(mycbr); 137 87 138 printf("done.\n"); 88 139 return 0;