Show
Ignore:
Timestamp:
07/16/09 22:53:04 (4 years ago)
Author:
hvolos
Message:

Added alamouti STBC

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/branches/hvolos/components/MIMODec/MIMODec.cpp

    r9338 r9452  
    1010#include "MIMODec.h" 
    1111 
     12using namespace arma; 
     13 
    1214MIMODec_i::MIMODec_i(const char *uuid, omni_condition *condition) :  
    1315    Resource_impl(uuid), component_running(condition)  
    1416{ 
    15     dataOut_0 = new standardInterfaces_i::complexShort_u("Symbols_OUT"); 
    16     dataIn_0 = new standardInterfaces_i::complexShort_p("MUX_MIMO_Symbols_IN"); 
     17    dataOut = new standardInterfaces_i::complexShort_u("Symbols_OUT"); 
     18    dataIn = new standardInterfaces_i::complexShort_p("MUX_MIMO_Symbols_IN"); 
    1719 
    1820    //Create the thread for the writer's processing function  
     
    2628MIMODec_i::~MIMODec_i(void) 
    2729{    
    28     delete dataOut_0; 
    29     delete dataIn_0; 
     30    delete dataOut; 
     31    delete dataIn; 
    3032} 
    3133 
     
    4345    CORBA::Object_var p; 
    4446 
    45     p = dataOut_0->getPort(portName); 
     47    p = dataOut->getPort(portName); 
    4648 
    4749    if (!CORBA::is_nil(p)) 
    4850        return p._retn(); 
    4951 
    50     p = dataIn_0->getPort(portName); 
     52    p = dataIn->getPort(portName); 
    5153 
    5254    if (!CORBA::is_nil(p)) 
     
    99101            CORBA::Short simple_temp; 
    100102            props[i].value >>= simple_temp; 
    101             simple_0_value = simple_temp; 
     103            Nt = simple_temp; 
    102104        } 
    103105 
    104106        if (strcmp(props[i].id, "DCE:74a38a7c-3b3e-11de-b7e0-0000e80014f9") == 0) 
    105107        { 
     108            const char * prop_str; 
     109            props[i].value >>= prop_str; 
     110            MIMOmethod=prop_str; 
     111        } 
     112         
     113        if (strcmp(props[i].id, "DCE:a1026f5c-3b3e-11de-b7e0-0000e80014f9") == 0) 
     114        { 
     115            CORBA::Short simple_temp; 
     116            props[i].value >>= simple_temp; 
     117            Mr = simple_temp; 
     118        } 
     119         
     120        if (strcmp(props[i].id, "DCE:17cabf40-3b3f-11de-b7e0-0000e80014f9") == 0) 
     121        { 
     122            const char * prop_str; 
     123            props[i].value >>= prop_str; 
     124            Modmethod=prop_str; 
     125        } 
     126      } 
    106127} 
    107128 
     
    110131    DEBUG(3, MIMODec, "ProcessData() invoked") 
    111132 
    112     PortTypes::ShortSequence I_out_0, Q_out_0; 
     133    PortTypes::ShortSequence I_out, Q_out; 
    113134 
    114135 
    115     PortTypes::ShortSequence *I_in_0(NULL), *Q_in_0(NULL); 
    116     CORBA::UShort I_in_0_length, Q_in_0_length; 
     136    PortTypes::ShortSequence *I_in(NULL), *Q_in(NULL); 
     137    CORBA::UShort Data_length; 
    117138 
    118139    while(1) 
    119140    { 
    120         dataIn_0->getData(I_in_0, Q_in_0); 
     141       short  int NH=4; 
     142        dataIn->getData(I_in, Q_in); 
    121143 
    122         I_in_0_length = I_in_0->length(); 
    123         Q_in_0_length = Q_in_0->length(); 
     144        Data_length = I_in->length(); 
    124145 
    125         I_out_0.length(); //must define length of output 
    126         Q_out_0.length(); //must define length of output 
     146 
     147        I_out.length((Data_length-NH)/2); //must define length of output 
     148        Q_out.length((Data_length-NH)/2); //must define length of output 
    127149 
    128150        /*insert code here to do work*/ 
     151         
     152        
     153        cx_mat H(2,2); 
     154        for (int i=0;i<2;i++){ 
     155                for (int j=0;j<2;j++){ 
     156                H(i,j)=cx_double((*I_in)[i*2+j],(*Q_in)[i*2+j])/10000.0; 
     157                //std::cout<<"Iin:"<<(*I_in)[i*2+j]; 
     158                } 
     159        } 
     160        //std::cout<<std::endl; 
     161         
     162        /*Alamouti 
     163        for i=1:2:length(RX_symbols1), 
     164          r1=RX_symbols1(i); 
     165          r2=RX_symbols1(i+1); 
     166          RX_symbols(i)=r1*conj(H(1,1))+conj(r2)*H(1,2); 
     167          RX_symbols(i+1)=r1*conj(H(1,2))-conj(r2)*H(1,1); 
     168        end; 
     169        */ 
     170 
     171        cx_double r1; 
     172        cx_double r2; 
     173        cx_mat rx_symbols(((Data_length-NH)/2),1); 
     174        short int j=0; 
     175        //std::cout<<"Decode"<<std::endl; 
     176        std::cout<<"Hdec="<<H; 
     177        for (short int i=NH; i<Data_length;i+=4){ 
     178                r1=cx_double((*I_in)[i],(*Q_in)[i]); 
     179                r2=cx_double((*I_in)[i+2],(*Q_in)[i+2]); 
     180               // std::cout<<((Data_length-NH)/2)<<" i:"<<i<<" j"<<j<<std::endl; 
     181                rx_symbols(j,0)=r1*conj(H(0,0))+conj(r2)*H(0,1); 
     182                rx_symbols(j+1,0)=r1*conj(H(0,1))-conj(r2)*H(0,0);                                             
     183                j+=2; 
     184        }  
     185         
     186        for (short int i=0; i<((Data_length-NH)/2);i++){ 
     187        I_out[i]=(CORBA::Short)real(rx_symbols(i,0)); 
     188        Q_out[i]=(CORBA::Short)imag(rx_symbols(i,0)); 
     189        std::cout<<"Symbol"<<rx_symbols(i,0)<<std::endl; 
     190        std::cout<<"I:"<<I_out[i]<<"Q:"<<Q_out[i]<<std::endl; 
     191        } 
    129192 
    130193 
    131  
    132  
    133  
    134  
    135         dataIn_0->bufferEmptied(); 
    136         dataOut_0->pushPacket(I_out_0, Q_out_0); 
     194        dataIn->bufferEmptied(); 
     195        dataOut->pushPacket(I_out, Q_out); 
    137196    } 
    138197}