Changeset 9452 for ossiedev/branches/hvolos/components/MIMODec/MIMODec.cpp
- Timestamp:
- 07/16/09 22:53:04 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
ossiedev/branches/hvolos/components/MIMODec/MIMODec.cpp
r9338 r9452 10 10 #include "MIMODec.h" 11 11 12 using namespace arma; 13 12 14 MIMODec_i::MIMODec_i(const char *uuid, omni_condition *condition) : 13 15 Resource_impl(uuid), component_running(condition) 14 16 { 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"); 17 19 18 20 //Create the thread for the writer's processing function … … 26 28 MIMODec_i::~MIMODec_i(void) 27 29 { 28 delete dataOut _0;29 delete dataIn _0;30 delete dataOut; 31 delete dataIn; 30 32 } 31 33 … … 43 45 CORBA::Object_var p; 44 46 45 p = dataOut _0->getPort(portName);47 p = dataOut->getPort(portName); 46 48 47 49 if (!CORBA::is_nil(p)) 48 50 return p._retn(); 49 51 50 p = dataIn _0->getPort(portName);52 p = dataIn->getPort(portName); 51 53 52 54 if (!CORBA::is_nil(p)) … … 99 101 CORBA::Short simple_temp; 100 102 props[i].value >>= simple_temp; 101 simple_0_value= simple_temp;103 Nt = simple_temp; 102 104 } 103 105 104 106 if (strcmp(props[i].id, "DCE:74a38a7c-3b3e-11de-b7e0-0000e80014f9") == 0) 105 107 { 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 } 106 127 } 107 128 … … 110 131 DEBUG(3, MIMODec, "ProcessData() invoked") 111 132 112 PortTypes::ShortSequence I_out _0, Q_out_0;133 PortTypes::ShortSequence I_out, Q_out; 113 134 114 135 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; 117 138 118 139 while(1) 119 140 { 120 dataIn_0->getData(I_in_0, Q_in_0); 141 short int NH=4; 142 dataIn->getData(I_in, Q_in); 121 143 122 I_in_0_length = I_in_0->length(); 123 Q_in_0_length = Q_in_0->length(); 144 Data_length = I_in->length(); 124 145 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 127 149 128 150 /*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 } 129 192 130 193 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); 137 196 } 138 197 }