[283] | 1 | /* Virginia Tech Cognitive Radio Open Source Systems |
---|
| 2 | * Virginia Tech, 2009 |
---|
| 3 | * |
---|
| 4 | * TODO LICENSE INFORMATION GOES HERE |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | /* TODO DESCRIPTION OF FILE. |
---|
| 8 | * |
---|
| 9 | * This file is a temporary demo of a policy engine using some of our socket |
---|
| 10 | * communication functions. This is *not* an actual implementation of our |
---|
| 11 | * defined PolicyEngine class. |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | #include <cstdlib> |
---|
| 16 | #include <cstring> |
---|
| 17 | #include <stdint.h> |
---|
| 18 | |
---|
| 19 | #include "vtcross/debug.h" |
---|
| 20 | #include "vtcross/error.h" |
---|
| 21 | #include "vtcross/libvtcross.h" |
---|
| 22 | #include "vtcross/socketcomm.h" |
---|
| 23 | |
---|
| 24 | int32_t |
---|
| 25 | main(int32_t argc, char *argv[]) |
---|
| 26 | { |
---|
| 27 | uint32_t ret = 0; |
---|
| 28 | |
---|
| 29 | uint32_t numParameters = 2; |
---|
| 30 | uint32_t numObservables = 2; |
---|
| 31 | |
---|
[285] | 32 | //for(size_t i = 0; i < 10; i++) { |
---|
[283] | 33 | |
---|
| 34 | Observable *o = new Observable[2]; |
---|
| 35 | Parameter *currentParameters = new Parameter[2]; |
---|
| 36 | Parameter *p; |
---|
| 37 | |
---|
| 38 | o[0].name = "throughput"; |
---|
| 39 | o[0].value = 150.00; |
---|
| 40 | o[1].name = "PER"; |
---|
| 41 | o[1].value = 12.00; |
---|
| 42 | |
---|
[285] | 43 | //if(i == 0) { |
---|
[283] | 44 | currentParameters[0].name = "bandwidth"; |
---|
| 45 | currentParameters[0].value = 300.0; |
---|
| 46 | currentParameters[1].name = "tx_power"; |
---|
| 47 | currentParameters[1].value = 10.0; |
---|
[285] | 48 | // } else { |
---|
| 49 | // currentParameters[0].value = p[0].value; |
---|
| 50 | // currentParameters[1].value = p[1].value; |
---|
| 51 | // } |
---|
[283] | 52 | |
---|
| 53 | |
---|
| 54 | // Set the currently active SML misson |
---|
| 55 | // Note: mission name must match a mission |
---|
| 56 | // in the SML xml file |
---|
[285] | 57 | SetActiveMission("0"); |
---|
[283] | 58 | |
---|
| 59 | // Send a request to the system for a new set of |
---|
| 60 | // parameters. |
---|
[285] | 61 | p = GetOptimalParameters(o,numObservables,currentParameters,numParameters); |
---|
[283] | 62 | |
---|
[285] | 63 | LOG("Application:: Received the following parameters.\n"); |
---|
[283] | 64 | |
---|
[285] | 65 | for(size_t i = 0; i < numParameters; i++) { |
---|
| 66 | LOG("%s:: %f\n", p[i].name.c_str(), p[i].value); |
---|
| 67 | } |
---|
[283] | 68 | |
---|
| 69 | // Simulate the REAL observable values after the |
---|
| 70 | // given parameters were set. |
---|
| 71 | |
---|
| 72 | //o[0].value = 0.5*p[0].value + .1*p[1].value; |
---|
| 73 | //o[1].value = 15-p[1].value; |
---|
| 74 | |
---|
| 75 | // Send the new observable values to the system with the |
---|
| 76 | // associated parameter set. |
---|
| 77 | //UpdateParameterPerformance(p, numParameters, o, numObservables); |
---|
| 78 | |
---|
| 79 | delete [] p; |
---|
| 80 | delete [] o; |
---|
[285] | 81 | //} |
---|
[283] | 82 | |
---|
| 83 | return 0; |
---|
| 84 | } |
---|
| 85 | |
---|