Show
Ignore:
Timestamp:
09/07/09 17:28:20 (15 years ago)
Author:
bhilburn
Message:

Moved over the necessary CBR functionality for DSA_CE using the new C++
classes. Note that CBR code is messy and needs to be cleaned up.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/src/cognitive_engines/DSA_CE/DSA_CognitiveEngine.cpp

    r465 r469  
    1818#include <cstring> 
    1919#include <stdint.h> 
    20 #include <math.h> 
    21  
     20#include <cmath> 
     21 
     22#include "vtcross/cbr.h" 
    2223#include "vtcross/cognitive_engine.h" 
    2324#include "vtcross/common.h" 
     
    2728#include "vtcross/error.h" 
    2829#include "vtcross/socketcomm.h" 
    29 #include "vtcross/cbr.h" 
    30  
    31 // TODO this is really bad; need to move to a proper cbr.h 
    32 #include "cbr.c" 
    33  
    34 #include "sqlite3.h" 
    35 #include "sqlite3ext.h" 
     30 
    3631 
    3732#define INTERFERENCE 0 
     
    4540 
    4641 
    47  
    48 static cbr myCBR; 
     42static CBR *myCBR; 
    4943 
    5044 
     
    6054CognitiveEngine::~CognitiveEngine() 
    6155{ 
    62     cbr_free(myCBR); 
     56    delete myCBR; 
    6357    delete [] pList; 
    6458    delete [] oList; 
     
    161155    std::string channel_name = "channel"; 
    162156    searchNames[0] = (char *) channel_name.c_str(); 
    163     searchOps[0] = EQ; 
     157    searchOps[0] = 0; 
    164158    searchVals[0] = parameters[0].value;  
    165159 
    166160    /* Execute CBR search and put output into returnValues */ 
    167     cbr_search(myCBR, searchNames, searchOps, searchVals, 
     161    myCBR->Search(searchNames, searchOps, searchVals, 
    168162            1, returnValues); 
    169163 
     
    197191    } 
    198192 
    199     cbr_update(myCBR, nameList, obsList, valList, obsVals,  
     193    myCBR->Update(nameList, obsList, valList, obsVals,  
    200194            numberColumns, obsColumns); 
    201195} 
     
    697691 
    698692        searchNames[0] = (char*) pList[0].name.c_str(); 
    699         searchOps[0] = EQ; 
     693        searchOps[0] = 0; 
    700694        searchVals[0] = i+1;  
    701695     
    702         uint32_t rc = cbr_search(myCBR, searchNames, searchOps, searchVals, 
     696        uint32_t rc = myCBR->Search(searchNames, searchOps, searchVals, 
    703697            1, returnValues); 
    704698 
     
    728722                /* Add the new optimized set to the CBR database */ 
    729723 
    730                 cbr_add_row(myCBR, rowNames, returnValues, numberColumns); 
     724                myCBR->AddRow(rowNames, returnValues, numberColumns); 
    731725        } 
    732726 
     
    737731    // Get sum of all the channel utilities. 
    738732    sumSearchName = (char *) utility_name.c_str(); 
    739     uint32_t rc = cbr_search_sum(myCBR, sumSearchName, sumRetVals); 
     733    uint32_t rc = myCBR->SearchSum(sumSearchName, sumRetVals); 
    740734 
    741735    // Psuedo random channel selection based upon utility. 
     
    752746         
    753747    searchNames[0] = (char*) pList[0].name.c_str(); 
    754     searchOps[0] = EQ; 
     748    searchOps[0] = 0; 
    755749    searchVals[0] = channel;  
    756750   
    757     rc = cbr_search(myCBR, searchNames, searchOps, searchVals, 
     751    rc = myCBR->Search(searchNames, searchOps, searchVals, 
    758752        1, returnValues); 
    759753 
     
    800794 
    801795    /* Add the new optimized set to the CBR database */ 
    802     cbr_add_row(myCBR, allNames, returnValues, returnValueIndex+1); 
     796    myCBR->AddRow(allNames, returnValues, returnValueIndex+1); 
    803797 
    804798 
     
    863857    cols[columnIndex] = (char *)utility_name.c_str(); 
    864858 
    865     myCBR = cbr_create_with_primary(filename, tablename, cols, paramCols, numberColumns, radioInfo->numParameters); 
    866 } 
    867  
     859    myCBR = new CBR(filename, tablename, cols, paramCols, numberColumns, radioInfo->numParameters); 
     860} 
     861