Changeset 410

Show
Ignore:
Timestamp:
08/03/09 10:12:34 (15 years ago)
Author:
trnewman
Message:

Added short README about benchmark_dsa.py

Using python dict instead of multiple if's.

Location:
vtcross/trunk/src/cognitive_engines/DSA_CE/examples/gnuradio-examples
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/src/cognitive_engines/DSA_CE/examples/gnuradio-examples/benchmark_dsa.py

    r409 r410  
    8282                real_channel = 1; 
    8383 
    84                 if channel == 1: 
    85                         real_channel = 1 
    86                 if channel == 2: 
    87                         real_channel = 7 
    88                 if channel == 3: 
    89                         real_channel = 8 
    90                 if channel == 4: 
    91                         real_channel = 14 
     84                get_channel = { 
     85                        1: 1, 
     86                        2: 7, 
     87                        3: 8, 
     88                        4: 14  
     89                        } 
     90 
     91                real_channel = get_channel[channel] 
    9292 
    9393                return real_channel 
     
    107107 
    108108                if cross == True: 
    109                         if hop_freq == 462562500: 
    110                                 channel = 1 
    111                         if hop_freq == 462712500: 
    112                                 channel = 2 
    113                         if hop_freq == 467562500: 
    114                                 channel = 3 
    115                         if hop_freq == 467712500: 
    116                                 channel = 4 
    117  
     109 
     110                        freq_channel = { 
     111                                462562500: 1, 
     112                                462712500: 2, 
     113                                467562500: 3, 
     114                                467712500: 4, 
     115                        } 
    118116                        currentParameters = Parameter(1) 
    119117                        currentParameters[0].name = "channel" 
    120                         currentParameters[0].value = channel 
     118                        currentParameters[0].value = freq_channel[hop_freq]  
    121119 
    122120                        o = Observable(2) 
     
    136134                        else: 
    137135                                # Get the average communication time 
    138                                 average_time = get_average_time(channel, absent_time) 
     136                                average_time = get_average_time(freq_channel[hop_freq], absent_time) 
    139137                                o[1].value = average_time  
    140138                                o[1].name = "communication_time" 
     
    150148                else: 
    151149                        channel = int(random.choice([1,7,8,14])) 
    152          
    153  
     150                         
    154151                if channel < 8: 
    155152                        hop_freq = float(1e6 * (462.5625+(channel-1)*0.025))#setting the centre freq frequency for sending packets