Changeset 7381

Show
Ignore:
Timestamp:
04/30/08 14:33:05 (5 years ago)
Author:
hvolos
Message:

Component saves ant/rcv level history to txt file and plothistory.m plots it every few seconds

Location:
ossiedev/branches/hvolos/ossie-sdrf2007/components/AGCwSWDIV
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/branches/hvolos/ossie-sdrf2007/components/AGCwSWDIV/src/AGCwSWDIV.cpp

    r7104 r7381  
    2424#include <string> 
    2525#include <iostream> 
     26#include <fstream> 
    2627#include <math.h> 
    2728#include "AGCwSWDIV.h" 
     
    253254    float avg_energy_ant1=0; 
    254255    float noise_floor; 
     256    int max_hist=1000; 
     257    float value_history[max_hist][2]; 
     258    int hist_count=0; 
     259    int hist_index=0; 
     260     
     261    std::ofstream outfile; 
    255262 
    256263 
     
    320327 
    321328        ant_energy=20.0f*log10f(ant_energy); 
     329         
     330        value_history[hist_index][0]=ant; 
     331        if (isinf(ant_energy)) 
     332        { 
     333        value_history[hist_index][1]=-50; 
     334        } 
     335        else 
     336        { 
     337        value_history[hist_index][1]=ant_energy; 
     338        } 
     339        hist_count++; 
     340        hist_index++; 
     341        if (hist_index>=max_hist) 
     342        { 
     343            hist_index=0; 
     344        } 
     345 
     346        if (hist_count>700) 
     347        { 
     348            outfile.open ("datahistory.txt",std::ios::out); 
     349            for (i=hist_index; i<max_hist;i++) 
     350            { 
     351            outfile<<value_history[i][0]<<","<<value_history[i][1]<<"\n"; 
     352 
     353            } 
     354 
     355            for (i=0; i<hist_index;i++) 
     356            { 
     357            outfile<<value_history[i][0]<<","<<value_history[i][1]<<"\n"; 
     358 
     359            } 
     360 
     361             
     362            outfile.close(); 
     363            hist_count=0; 
     364        } 
    322365 
    323366 
     
    326369        metadata->signal_strength =20.0f*log10f(energy/gain); 
    327370 
     371 
    328372        if  (ant==0) 
    329373        
     
    331375                    //0 is the RX/TX port 
    332376                    ant_energy-=rx_ant_0_cal; 
    333                     noise_floor=-0-rx_ant_0_cal;    
     377                    noise_floor=-10-rx_ant_0_cal;    
    334378                } 
    335379            else 
    336380                { 
    337381                    ant_energy-=rx_ant_1_cal; 
    338                     noise_floor=-0-rx_ant_1_cal;   
     382                    noise_floor=-10-rx_ant_1_cal;   
    339383                } 
    340384      
    341385         
    342386         
    343          
     387         //metadata->signal_strength =ant; 
     388//DEBUG(3, AGCwSWDIV, "Ant Energy" <<ant_energy <<"dB " <<", Signal Strength:"<<metadata->signal_strength<<"dB, ant:"<<ant) 
    344389/** 
    345  
    346         if ((ant_energy>-noise_floor)&(!isinf(ant_energy))) 
     390        if ((ant_energy>noise_floor)&(!isinf(ant_energy))) 
    347391        { 
    348392            DEBUG(3, AGCwSWDIV, "Ant Energy" <<ant_energy <<"dB " <<", Signal Strength:"<<metadata->signal_strength<<"dB, ant:"<<ant) 
     
    375419            std::cout<<"Ant 0 Avg. Energy:"<<avg_energy_ant0/count_ant0<<" dB "<<"Ant 1 Avg. Energy:"<<avg_energy_ant1/count_ant1<<" dB"<<std::endl; 
    376420        } 
    377 */     //DEBUG(3, AGCwSWDIV, "Ant Energy" <<ant_energy <<"dB " <<", Signal Strength:"<<metadata->signal_strength<<"dB, ant:"<<ant) 
     421**/ 
     422     //DEBUG(3, AGCwSWDIV, "Ant Energy" <<ant_energy <<"dB " <<", Signal Strength:"<<metadata->signal_strength<<"dB, ant:"<<ant) 
    378423 
    379424        if ((ant_energy<sw_ant_thresh)&(ant_energy>noise_floor)&(!isinf(ant_energy))) 
     
    387432                ant=1; 
    388433             
    389             //std::cout<<"ant:"<<ant<<"."; 
     434           // std::cout<<":"<<ant<<"."; 
     435             //       rx_config[0].id = CORBA::string_dup("SET_RX_ANT_1"); 
     436        rx_config[0].value <<= (CORBA::ULong) ant; 
     437        //std::cout<<"Attempting to write to port"<<std::endl; 
     438        rx_control->set_values(rx_config); 
     439 
    390440        } 
    391441         
     
    400450 
    401451        // empty input buffer 
     452 
     453 
    402454        dataIn_0->bufferEmptied(); 
    403455