Changeset 390
- Timestamp:
- 07/29/09 00:31:04 (15 years ago)
- Location:
- vtcross/trunk/src/cognitive_engines/DSA_CE
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/src/cognitive_engines/DSA_CE/DSA_CognitiveEngine.cpp
r389 r390 44 44 SML_present = false; 45 45 commandSocketFD = -1; 46 srand ( time(NULL) ); 46 47 } 47 48 … … 274 275 LOG("Cognitive Engine:: Processing parameters....\n"); 275 276 276 Parameter *solutionSet;277 278 //solutionSet = GetSolution(o,cp);279 280 277 // TODO need to actually do something with the observables here 281 278 282 279 LOG("Cognitive Engine:: Sending Optimal Parameters to Application.\n"); 283 280 char numParametersChar[10]; 284 char solutionValue[50];285 281 sprintf(numParametersChar, "%i", radioInfo->numParameters); 286 282 SendMessage(commandSocketFD, numParametersChar); 287 283 for(size_t i = 0; i < radioInfo->numParameters; i++) { 288 //SendMessage(commandSocketFD, solutionSet[i].name.c_str());289 284 SendMessage(commandSocketFD, "test"); 290 //memset(solutionValue, 0, 50);291 //sprintf(solutionValue, "%f", solutionSet[i].value);292 //SendMessage(commandSocketFD, solutionValue);293 285 SendMessage(commandSocketFD, "00"); 294 286 } … … 649 641 /* Put together the CBR search array */ 650 642 651 char *searchNames[ radioInfo->numUtilities +1];652 float searchVals[ radioInfo->numUtilities +1];653 int searchOps[ radioInfo->numUtilities +1];643 char *searchNames[1]; 644 float searchVals[1]; 645 int searchOps[1]; 654 646 uint32_t numberColumns = radioInfo->numUtilities + 655 647 radioInfo->numParameters + 656 648 radioInfo->numObservables + 1; 657 649 658 for(size_t i = 0; i < radioInfo->numUtilities; i++) {659 searchNames[i] = (char*)uList[i].name.c_str();660 661 if(strcmp(uList[i].goal.c_str(), "max") == 0) {662 searchOps[i] = GT;663 } else if(strcmp(uList[i].goal.c_str(), "min") == 0) {664 searchOps[i] = LT;665 }666 667 /* Set search target to utility target */668 /* This may be bad if no target is set */669 searchVals[i] = uList[i].target;670 }671 672 673 650 /* Make sure we do not return any entries for the current channel */ 674 searchNames[ radioInfo->numUtilities+1] = "channel";675 searchOps[ radioInfo->numUtilities+1] = NE;676 searchVals[ radioInfo->numUtilities+1] = currentParameters[0].value;651 searchNames[0] = "channel"; 652 searchOps[0] = NE; 653 searchVals[0] = currentParameters[0].value; 677 654 678 655 float returnValues[numberColumns]; … … 680 657 /* Execute CBR search and put output into returnValues */ 681 658 uint32_t rc = cbr_search(myCBR, searchNames, searchOps, searchVals, 682 radioInfo->numUtilities, returnValues);659 1, returnValues); 683 660 684 661 if(rc == 0){ … … 688 665 LOG("Cognitive Engine:: Previous similar environment found\n"); 689 666 667 /* generate random channel */ 668 returnValues[CHANNEL] = rand() % (int)pList[0].max + (int)pList[0].min; 669 690 670 if(returnValues[numberColumns-1] < 0) { 691 692 returnValues[2] = returnValues[2] - 15;693 returnValues[3] = returnValues[3] - 2;694 671 695 672 } else { 696 673 697 returnValues[2] = returnValues[2] + 15;698 returnValues[3] = returnValues[3] + 2;699 700 674 } 701 675 } else if(rc == 31337) { … … 703 677 LOG("Cognitive Engine:: No previous similar environment found.\n"); 704 678 705 /* In the DSA case, the default is to select a random channel */706 707 /* initialize random seed: */708 srand ( time(NULL) );709 710 679 /* generate random channel */ 711 //returnValues[CHANNEL] = rand() % currentParameters[0].max + currentParameters[0].min; 712 returnValues[CHANNEL] = rand() % 5; 713 714 printf("One: %i Two: %i\n",(int)currentParameters[0].max,(int)currentParameters[0].min); 715 680 returnValues[CHANNEL] = rand() % (int)pList[0].max + (int)pList[0].min; 716 681 } else { 717 682 LOG("Cognitive Engine:: Search return an invalid value.\n"); -
vtcross/trunk/src/cognitive_engines/DSA_CE/cbr.c
r389 r390 202 202 unsigned int i; 203 203 char str_buffer[64]; 204 printf("number of ops %d:\n", _n);205 204 for (i=0; i<_n; i++) { 206 205 // ensure valid ops value … … 221 220 } 222 221 223 //printf("search command: %s\n", _cbr->command);222 printf("search command: %s\n", _cbr->command); 224 223 225 224 rc = ExecuteSearchCommand(_cbr, _retvals); -
vtcross/trunk/src/cognitive_engines/DSA_CE/examples/gnuradio-examples/dsa.py
r389 r390 47 47 def send_pkt(self, payload='', eof=False): 48 48 return self.txpath.send_pkt(payload, eof) 49 49 50 def get_real_channel(channel): 51 52 real_channel = 1; 53 54 if channel == 1: 55 real_channel = 1 56 if channel == 2: 57 real_channel = 7 58 if channel == 3: 59 real_channel = 8 60 if channel == 4: 61 real_channel = 14 62 63 return real_channel 64 50 65 def get_freq(hop_freq,probe_level,absent_time): 51 66 … … 55 70 channel = 1 56 71 if hop_freq == 462712500: 57 channel = 772 channel = 2 58 73 if hop_freq == 467562500: 59 channel = 874 channel = 3 60 75 if hop_freq == 467712500: 61 channel = 1476 channel = 4 62 77 63 78 p = Parameter(1) … … 72 87 73 88 p = GetOptimalParameters(o,1,currentParameters,1); 74 print p[0].name, p[0].value 75 89 print p[0].value 90 91 channel = get_real_channel(int(p[0].value)) 92 76 93 if channel < 8: 77 94 hop_freq = float(1e6 * (462.5625+(channel-1)*0.025))#setting the centre freq frequency for sending packets … … 153 170 help="use file for packet contents") 154 171 155 172 transmit_path.add_options(parser_tx, expert_grp_tx) 156 173 157 174 for mod in mods.values(): … … 228 245 ch_energy = tb.rxpath.probe.level() #setting initial value 229 246 hop_freq = options_tx.tx_freq # = options_rx.rx_freq...same for tx and rx side 230 while running: 247 248 249 # Scan all channels first for inital data 250 251 while running: 231 252 232 253 ################################################sync mode####################################