| 1 | /**************************************************************************** |
|---|
| 2 | |
|---|
| 3 | Copyright 2007 Virginia Polytechnic Institute and State University |
|---|
| 4 | |
|---|
| 5 | This file is part of the OSSIE FrameAssembler_metadata. |
|---|
| 6 | |
|---|
| 7 | OSSIE FrameAssembler_metadata is free software; you can redistribute it and/or modify |
|---|
| 8 | it under the terms of the GNU General Public License as published by |
|---|
| 9 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | (at your option) any later version. |
|---|
| 11 | |
|---|
| 12 | OSSIE FrameAssembler_metadata is distributed in the hope that it will be useful, |
|---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | GNU General Public License for more details. |
|---|
| 16 | |
|---|
| 17 | You should have received a copy of the GNU General Public License |
|---|
| 18 | along with OSSIE FrameAssembler_metadata; if not, write to the Free Software |
|---|
| 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | |
|---|
| 21 | ****************************************************************************/ |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | #include <string> |
|---|
| 25 | #include <iostream> |
|---|
| 26 | #include "FrameAssembler_metadata.h" |
|---|
| 27 | |
|---|
| 28 | FrameAssembler_metadata_i::FrameAssembler_metadata_i(const char *uuid, omni_condition *condition) : |
|---|
| 29 | Resource_impl(uuid), component_running(condition) |
|---|
| 30 | { |
|---|
| 31 | dataIn_0 = new standardInterfaces_i::complexShort_p("SymbolsIn"); |
|---|
| 32 | dataOut_0 = new standardInterfaces_i::complexShort_u("FrameSymbolsOut"); |
|---|
| 33 | |
|---|
| 34 | num_frames_sent_app_1 = 0; |
|---|
| 35 | num_frames_sent_app_2 = 0; |
|---|
| 36 | num_frames_sent_app_5 = 0; |
|---|
| 37 | num_frames_sent_app_6 = 0; |
|---|
| 38 | |
|---|
| 39 | //Create the thread for the writer's processing function |
|---|
| 40 | processing_thread = new omni_thread(Run, (void *) this); |
|---|
| 41 | |
|---|
| 42 | //Start the thread containing the writer's processing function |
|---|
| 43 | processing_thread->start(); |
|---|
| 44 | |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | FrameAssembler_metadata_i::~FrameAssembler_metadata_i(void) |
|---|
| 48 | { |
|---|
| 49 | delete dataIn_0; |
|---|
| 50 | delete dataOut_0; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | // Static function for omni thread |
|---|
| 54 | void FrameAssembler_metadata_i::Run( void * data ) |
|---|
| 55 | { |
|---|
| 56 | ((FrameAssembler_metadata_i*)data)->ProcessData(); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | CORBA::Object_ptr FrameAssembler_metadata_i::getPort( const char* portName ) throw ( |
|---|
| 60 | CORBA::SystemException, CF::PortSupplier::UnknownPort) |
|---|
| 61 | { |
|---|
| 62 | DEBUG(3, FrameAssembler_metadata, "getPort() invoked with " << portName) |
|---|
| 63 | |
|---|
| 64 | CORBA::Object_var p; |
|---|
| 65 | |
|---|
| 66 | p = dataIn_0->getPort(portName); |
|---|
| 67 | |
|---|
| 68 | if (!CORBA::is_nil(p)) |
|---|
| 69 | return p._retn(); |
|---|
| 70 | |
|---|
| 71 | p = dataOut_0->getPort(portName); |
|---|
| 72 | |
|---|
| 73 | if (!CORBA::is_nil(p)) |
|---|
| 74 | return p._retn(); |
|---|
| 75 | |
|---|
| 76 | // Requested port not recognized |
|---|
| 77 | throw CF::PortSupplier::UnknownPort(); |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | void FrameAssembler_metadata_i::start() throw (CORBA::SystemException, |
|---|
| 81 | CF::Resource::StartError) |
|---|
| 82 | { |
|---|
| 83 | DEBUG(3, FrameAssembler_metadata, "start() invoked") |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | void FrameAssembler_metadata_i::stop() throw (CORBA::SystemException, CF::Resource::StopError) |
|---|
| 87 | { |
|---|
| 88 | DEBUG(3, FrameAssembler_metadata, "stop() invoked") |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | void FrameAssembler_metadata_i::releaseObject() throw (CORBA::SystemException, |
|---|
| 92 | CF::LifeCycle::ReleaseError) |
|---|
| 93 | { |
|---|
| 94 | DEBUG(3, FrameAssembler_metadata, "releaseObject() invoked") |
|---|
| 95 | |
|---|
| 96 | component_running->signal(); |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | void FrameAssembler_metadata_i::initialize() throw (CF::LifeCycle::InitializeError, |
|---|
| 100 | CORBA::SystemException) |
|---|
| 101 | { |
|---|
| 102 | DEBUG(3, FrameAssembler_metadata, "initialize() invoked") |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | void FrameAssembler_metadata_i::configure(const CF::Properties& props) |
|---|
| 106 | throw (CORBA::SystemException, |
|---|
| 107 | CF::PropertySet::InvalidConfiguration, |
|---|
| 108 | CF::PropertySet::PartialConfiguration) |
|---|
| 109 | { |
|---|
| 110 | DEBUG(3, FrameAssembler_metadata, "configure() invoked") |
|---|
| 111 | |
|---|
| 112 | std::cout << "props length : " << props.length() << std::endl; |
|---|
| 113 | |
|---|
| 114 | for (unsigned int i = 0; i <props.length(); i++) { |
|---|
| 115 | std::cout << "Property id : " << props[i].id << std::endl; |
|---|
| 116 | |
|---|
| 117 | if (strcmp(props[i].id, "DCE:c15e70e4-96e4-4cc8-b1f0-06cb301f6c2e") == 0) { |
|---|
| 118 | // Modulation type |
|---|
| 119 | const char * prop_str; |
|---|
| 120 | props[i].value >>= prop_str; |
|---|
| 121 | |
|---|
| 122 | // Set appropriate modulation function |
|---|
| 123 | if ( strcmp(prop_str, "BPSK") == 0 ) { |
|---|
| 124 | ConfigureModulationScheme(SigProc::BPSK); |
|---|
| 125 | } else if ( strcmp(prop_str, "QPSK") == 0 ) { |
|---|
| 126 | ConfigureModulationScheme(SigProc::QPSK); |
|---|
| 127 | } else if ( strcmp(prop_str, "8PSK") == 0 ) { |
|---|
| 128 | ConfigureModulationScheme(SigProc::PSK8); |
|---|
| 129 | } else if ( strcmp(prop_str, "16QAM") == 0 ) { |
|---|
| 130 | ConfigureModulationScheme(SigProc::QAM16); |
|---|
| 131 | } else if ( strcmp(prop_str, "4PAM") == 0 ) { |
|---|
| 132 | ConfigureModulationScheme(SigProc::PAM4); |
|---|
| 133 | } else { |
|---|
| 134 | // unknown property |
|---|
| 135 | std::cerr << "ERROR: FrameAssembler_metadata::configure() unknown mod. scheme " |
|---|
| 136 | << prop_str << std::endl; |
|---|
| 137 | throw CF::PropertySet::InvalidConfiguration(); |
|---|
| 138 | } |
|---|
| 139 | ///\todo catch exception thrown by FrameAssembler_metadataDSP::ConfigureModulationScheme() |
|---|
| 140 | |
|---|
| 141 | } else if (strcmp(props[i].id, "DCE:06b798ba-5412-4bbe-bf0b-8ca665d25b83") == 0) { |
|---|
| 142 | // Frame size |
|---|
| 143 | CORBA::UShort simple_temp; |
|---|
| 144 | props[i].value >>= simple_temp; |
|---|
| 145 | |
|---|
| 146 | ConfigureFrameSize(simple_temp); |
|---|
| 147 | |
|---|
| 148 | } else { |
|---|
| 149 | // unknown property |
|---|
| 150 | std::cerr << "ERROR: FrameAssembler_metadata::configure() unknown property" << std::endl; |
|---|
| 151 | throw CF::PropertySet::InvalidConfiguration(); |
|---|
| 152 | } |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | } |
|---|
| 156 | |
|---|
| 157 | void FrameAssembler_metadata_i::ConfigureModulationSchemeOnMetaData() { |
|---|
| 158 | switch (metadata->modulation_scheme.scheme) { |
|---|
| 159 | case standardInterfaces::ModulationScheme::PSK: |
|---|
| 160 | switch (metadata->modulation_scheme.M) { |
|---|
| 161 | case 2: |
|---|
| 162 | ConfigureModulationScheme(SigProc::BPSK); |
|---|
| 163 | DEBUG(5, FrameAssembler_metadata, "Frame mod set to BPSK"); |
|---|
| 164 | break; |
|---|
| 165 | case 4: |
|---|
| 166 | ConfigureModulationScheme(SigProc::QPSK); |
|---|
| 167 | DEBUG(5, FrameAssembler_metadata, "Frame mod set to QPSK"); |
|---|
| 168 | break; |
|---|
| 169 | case 8: |
|---|
| 170 | ConfigureModulationScheme(SigProc::PSK8); |
|---|
| 171 | DEBUG(5, FrameAssembler_metadata, "Frame mod set to 8PSK"); |
|---|
| 172 | break; |
|---|
| 173 | default: |
|---|
| 174 | std::cerr << "FrameAssembler_metadata-metadata: Unsupported PSK modulation depth" << std::endl; |
|---|
| 175 | throw 0; |
|---|
| 176 | } |
|---|
| 177 | break; |
|---|
| 178 | case standardInterfaces::ModulationScheme::QAM: |
|---|
| 179 | switch (metadata->modulation_scheme.M) { |
|---|
| 180 | case 4: |
|---|
| 181 | ConfigureModulationScheme(SigProc::QPSK); |
|---|
| 182 | DEBUG(5, FrameAssembler_metadata, "Frame mod set to QPSK (4QAM)"); |
|---|
| 183 | break; |
|---|
| 184 | case 16: |
|---|
| 185 | ConfigureModulationScheme(SigProc::QAM16); |
|---|
| 186 | DEBUG(5, FrameAssembler_metadata, "Frame mod set to 16QAM"); |
|---|
| 187 | break; |
|---|
| 188 | default: |
|---|
| 189 | std::cerr << "FrameAssembler_metadata-metadata: Unsupported QAM modulation depth" << std::endl; |
|---|
| 190 | throw 0; |
|---|
| 191 | } |
|---|
| 192 | break; |
|---|
| 193 | case standardInterfaces::ModulationScheme::PAM: |
|---|
| 194 | switch (metadata->modulation_scheme.M) { |
|---|
| 195 | case 4: |
|---|
| 196 | ConfigureModulationScheme(SigProc::PAM4); |
|---|
| 197 | DEBUG(5, FrameAssembler_metadata, "Frame mod set to 4PAM"); |
|---|
| 198 | break; |
|---|
| 199 | default: |
|---|
| 200 | std::cerr << "FrameAssembler_metadata-metadata: Unsupported PAM modulation depth" << std::endl; |
|---|
| 201 | throw 0; |
|---|
| 202 | } |
|---|
| 203 | break; |
|---|
| 204 | case standardInterfaces::ModulationScheme::UNKNOWN: |
|---|
| 205 | default:; |
|---|
| 206 | } |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | void FrameAssembler_metadata_i::ProcessData() |
|---|
| 213 | { |
|---|
| 214 | DEBUG(3, FrameAssembler_metadata, "ProcessData() invoked") |
|---|
| 215 | |
|---|
| 216 | PortTypes::ShortSequence I_out_header, Q_out_header; |
|---|
| 217 | PortTypes::ShortSequence I_out_data, Q_out_data; |
|---|
| 218 | PortTypes::ShortSequence I_out_0, Q_out_0; |
|---|
| 219 | |
|---|
| 220 | PortTypes::ShortSequence *I_in_0(NULL), *Q_in_0(NULL); |
|---|
| 221 | unsigned int N_in(0); |
|---|
| 222 | unsigned int j(0); |
|---|
| 223 | unsigned int blockSize(512); |
|---|
| 224 | |
|---|
| 225 | // Prepare preamble phasing pattern, ramp up/down |
|---|
| 226 | short * I_phasing_pattern = new short[512]; |
|---|
| 227 | short * Q_phasing_pattern = new short[512]; |
|---|
| 228 | PortTypes::ShortSequence I_out_phasing_pattern, Q_out_phasing_pattern; |
|---|
| 229 | I_out_phasing_pattern.length(256); |
|---|
| 230 | Q_out_phasing_pattern.length(256); |
|---|
| 231 | PortTypes::ShortSequence I_out_ramp_up, Q_out_ramp_up; |
|---|
| 232 | I_out_ramp_up.length(256); |
|---|
| 233 | Q_out_ramp_up.length(256); |
|---|
| 234 | PortTypes::ShortSequence I_out_ramp_down, Q_out_ramp_down; |
|---|
| 235 | I_out_ramp_down.length(256); |
|---|
| 236 | Q_out_ramp_down.length(256); |
|---|
| 237 | |
|---|
| 238 | AssemblePhasingPattern(I_phasing_pattern, Q_phasing_pattern); |
|---|
| 239 | for (unsigned int i=0; i<256; i++) { |
|---|
| 240 | I_out_phasing_pattern[i] = I_phasing_pattern[i]; |
|---|
| 241 | Q_out_phasing_pattern[i] = Q_phasing_pattern[i]; |
|---|
| 242 | |
|---|
| 243 | I_out_ramp_up[i] = (short) (I_phasing_pattern[i] * (0.5 - 0.5*cos( PI*i/256 ))); |
|---|
| 244 | Q_out_ramp_up[i] = (short) (Q_phasing_pattern[i] * (0.5 - 0.5*cos( PI*i/256 ))); |
|---|
| 245 | |
|---|
| 246 | I_out_ramp_down[i] = 1 - I_out_ramp_up[i]; |
|---|
| 247 | Q_out_ramp_down[i] = 1 - Q_out_ramp_up[i]; |
|---|
| 248 | } |
|---|
| 249 | |
|---|
| 250 | // control |
|---|
| 251 | PortTypes::ShortSequence I_out_control, Q_out_control; |
|---|
| 252 | I_out_control.length(1024); |
|---|
| 253 | Q_out_control.length(1024); |
|---|
| 254 | for (unsigned int i=0; i<256; i++) { |
|---|
| 255 | I_out_control[i] = (i%2 == 0) ? -BPSK_LEVEL : BPSK_LEVEL; |
|---|
| 256 | Q_out_control[i] = 0; |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | delete [] I_phasing_pattern; |
|---|
| 260 | delete [] Q_phasing_pattern; |
|---|
| 261 | |
|---|
| 262 | |
|---|
| 263 | short * I_header = new short[512]; |
|---|
| 264 | short * Q_header = new short[512]; |
|---|
| 265 | |
|---|
| 266 | while( true ) { |
|---|
| 267 | |
|---|
| 268 | numFrameSymbolsAssembled = 0; |
|---|
| 269 | |
|---|
| 270 | while ( numFrameSymbolsAssembled < (frameSize-1) ) { |
|---|
| 271 | // Get data from port |
|---|
| 272 | //dataIn_0->getData(I_in_0, Q_in_0, metadata); |
|---|
| 273 | dataIn_0->getData(I_in_0, Q_in_0); |
|---|
| 274 | // Read input data length |
|---|
| 275 | N_in = I_in_0->length(); |
|---|
| 276 | DEBUG(1, FrameAssembler_metadata, "got " << N_in << " samples"); |
|---|
| 277 | |
|---|
| 278 | |
|---|
| 279 | /* HV |
|---|
| 280 | if (metadata->app_id==0) { |
|---|
| 281 | // control packet; configure |
|---|
| 282 | DEBUG(1, FrameAssembler_metadata, "configuring end-of-frame control (app_id = 0)"); |
|---|
| 283 | if (N_in != 1024) { |
|---|
| 284 | std::cerr << "ERROR! FrameAssembler_metadata: control packet is wrong length!" |
|---|
| 285 | << std::endl; |
|---|
| 286 | throw 0; |
|---|
| 287 | } |
|---|
| 288 | |
|---|
| 289 | for (unsigned int i=0; i<N_in; i++) { |
|---|
| 290 | I_out_control[i] = (*I_in_0)[i]; |
|---|
| 291 | Q_out_control[i] = (*Q_in_0)[i]; |
|---|
| 292 | } |
|---|
| 293 | dataIn_0->bufferEmptied(); |
|---|
| 294 | continue; |
|---|
| 295 | } |
|---|
| 296 | */ |
|---|
| 297 | |
|---|
| 298 | if ( numFrameSymbolsAssembled==0 ) { |
|---|
| 299 | // first packet |
|---|
| 300 | ConfigureModulationScheme(SigProc::QPSK); |
|---|
| 301 | |
|---|
| 302 | /* HV |
|---|
| 303 | ConfigureModulationSchemeOnMetaData(); |
|---|
| 304 | |
|---|
| 305 | if (metadata->app_id==5) { |
|---|
| 306 | DEBUG(1, FrameAssembler_metadata, "configuring special control frame (app_id = 5)"); |
|---|
| 307 | ConfigureFrameType(FRAME_TYPE_CONTROL); |
|---|
| 308 | // control frame |
|---|
| 309 | if (N_in != frameSize) { |
|---|
| 310 | std::cerr << "ERROR! FrameAssembler_metadata: control packet (app_id=5) is wrong length!" |
|---|
| 311 | << std::endl; |
|---|
| 312 | throw 0; |
|---|
| 313 | } |
|---|
| 314 | num_frames_sent_app_5++; |
|---|
| 315 | } else if (metadata->app_id==6) { |
|---|
| 316 | DEBUG(1, FrameAssembler_metadata, "configuring special beacon frame (app_id = 6)"); |
|---|
| 317 | ConfigureFrameType(FRAME_TYPE_CONTROL); |
|---|
| 318 | // control frame |
|---|
| 319 | if (N_in != frameSize) { |
|---|
| 320 | std::cerr << "ERROR! FrameAssembler_metadata: control packet (app_id=6) is wrong length!" |
|---|
| 321 | << std::endl; |
|---|
| 322 | throw 0; |
|---|
| 323 | } |
|---|
| 324 | num_frames_sent_app_6++; |
|---|
| 325 | } else if (metadata->app_id==1) { |
|---|
| 326 | // audio data |
|---|
| 327 | ConfigureFrameType(FRAME_TYPE_DATA); |
|---|
| 328 | ///todo configure for BPSK |
|---|
| 329 | if (metadata->modulation_scheme.M == 4) |
|---|
| 330 | ConfigureFrameSize(8192); // QPSK |
|---|
| 331 | else |
|---|
| 332 | ConfigureFrameSize(4096); // 16-QAM |
|---|
| 333 | num_frames_sent_app_1++; |
|---|
| 334 | } else if (metadata->app_id==2) { |
|---|
| 335 | // text data |
|---|
| 336 | ConfigureFrameType(FRAME_TYPE_DATA); |
|---|
| 337 | ConfigureFrameSize(512); |
|---|
| 338 | num_frames_sent_app_2++; |
|---|
| 339 | } else { |
|---|
| 340 | std::cerr << "ERROR! FrameAssembler_metadata: Unknown app_id: " |
|---|
| 341 | << metadata->app_id << std::endl; |
|---|
| 342 | throw 0; |
|---|
| 343 | } |
|---|
| 344 | */ |
|---|
| 345 | |
|---|
| 346 | //HV audio data |
|---|
| 347 | ConfigureFrameType(FRAME_TYPE_DATA); |
|---|
| 348 | ///todo configure for BPSK |
|---|
| 349 | //if (metadata->modulation_scheme.M == 4) |
|---|
| 350 | // ConfigureFrameSize(8192); // QPSK |
|---|
| 351 | //else |
|---|
| 352 | ConfigureFrameSize(4096); // 16-QAM |
|---|
| 353 | num_frames_sent_app_1++; |
|---|
| 354 | |
|---|
| 355 | I_out_data.length(frameSize); |
|---|
| 356 | Q_out_data.length(frameSize); |
|---|
| 357 | } |
|---|
| 358 | |
|---|
| 359 | DEBUG(1, FrameAssembler_metadata, "Assembling " << N_in << " symbols (max: " << frameSize); |
|---|
| 360 | |
|---|
| 361 | for (unsigned int i=0; i<N_in; i++) { |
|---|
| 362 | // |
|---|
| 363 | I_out_data[numFrameSymbolsAssembled] = (*I_in_0)[i]; |
|---|
| 364 | Q_out_data[numFrameSymbolsAssembled] = (*Q_in_0)[i]; |
|---|
| 365 | |
|---|
| 366 | numFrameSymbolsAssembled++; |
|---|
| 367 | } |
|---|
| 368 | |
|---|
| 369 | // empty input buffer; release semaphore |
|---|
| 370 | dataIn_0->bufferEmptied(); |
|---|
| 371 | |
|---|
| 372 | } |
|---|
| 373 | |
|---|
| 374 | // ASSEMBLE_PREAMBLE |
|---|
| 375 | DEBUG(4, FrameAssembler_metadata, "Assembling preamble") |
|---|
| 376 | //HV metadata->port_id = 0; |
|---|
| 377 | |
|---|
| 378 | // push ramp-up preamble phasing pattern |
|---|
| 379 | DEBUG(7, FrameAssembler_metadata, "pushing ramp up phasing " << I_out_ramp_up.length() << " frame samples") |
|---|
| 380 | // dataOut_0->pushPacket(I_out_ramp_up, Q_out_ramp_up, *metadata); |
|---|
| 381 | dataOut_0->pushPacket(I_out_ramp_up, Q_out_ramp_up); |
|---|
| 382 | |
|---|
| 383 | // push preamble |
|---|
| 384 | unsigned int phasing_pattern_length; |
|---|
| 385 | /* HV |
|---|
| 386 | if (metadata->app_id==6) |
|---|
| 387 | phasing_pattern_length = 16; |
|---|
| 388 | else if (metadata->app_id==1) |
|---|
| 389 | phasing_pattern_length = 32; |
|---|
| 390 | else if (metadata->app_id==0) |
|---|
| 391 | phasing_pattern_length = 8; |
|---|
| 392 | else if (metadata->app_id==5) |
|---|
| 393 | phasing_pattern_length = 32; |
|---|
| 394 | else |
|---|
| 395 | phasing_pattern_length = 8; |
|---|
| 396 | */ |
|---|
| 397 | |
|---|
| 398 | phasing_pattern_length = 32; |
|---|
| 399 | |
|---|
| 400 | for (unsigned int i=0; i<phasing_pattern_length; i++) { |
|---|
| 401 | DEBUG(7, FrameAssembler_metadata, "pushing phasing " << I_out_phasing_pattern.length() << " frame samples") |
|---|
| 402 | //dataOut_0->pushPacket(I_out_phasing_pattern, Q_out_phasing_pattern, *metadata); |
|---|
| 403 | dataOut_0->pushPacket(I_out_phasing_pattern, Q_out_phasing_pattern); |
|---|
| 404 | } |
|---|
| 405 | |
|---|
| 406 | // ASSEMBLE_HEADER |
|---|
| 407 | DEBUG(4, FrameAssembler_metadata, "Assembling header") |
|---|
| 408 | // copy header |
|---|
| 409 | I_out_header.length(512); |
|---|
| 410 | Q_out_header.length(512); |
|---|
| 411 | AssembleHeader( I_header, Q_header ); |
|---|
| 412 | for (unsigned int i=0; i<512; i++) { |
|---|
| 413 | I_out_header[i] = I_header[i]; |
|---|
| 414 | Q_out_header[i] = Q_header[i]; |
|---|
| 415 | } |
|---|
| 416 | |
|---|
| 417 | // push data |
|---|
| 418 | DEBUG(7, FrameAssembler_metadata, "pushing header " << I_out_header.length() << " frame samples") |
|---|
| 419 | //dataOut_0->pushPacket(I_out_header, Q_out_header, *metadata); |
|---|
| 420 | dataOut_0->pushPacket(I_out_header, Q_out_header); |
|---|
| 421 | |
|---|
| 422 | |
|---|
| 423 | // ASSEMBLE_FRAME |
|---|
| 424 | // break output into smaller pieces |
|---|
| 425 | |
|---|
| 426 | I_out_0.length(blockSize); |
|---|
| 427 | Q_out_0.length(blockSize); |
|---|
| 428 | |
|---|
| 429 | j = 0; |
|---|
| 430 | for ( unsigned int i=0; i<frameSize; i++ ) { |
|---|
| 431 | I_out_0[j] = I_out_data[i]; |
|---|
| 432 | Q_out_0[j] = Q_out_data[i]; |
|---|
| 433 | j++; |
|---|
| 434 | |
|---|
| 435 | if ( j==blockSize || i==(frameSize-1) ) { |
|---|
| 436 | I_out_0.length(j); |
|---|
| 437 | Q_out_0.length(j); |
|---|
| 438 | DEBUG(7, FrameAssembler_metadata, "pushing frame " << I_out_0.length() << " frame samples") |
|---|
| 439 | //dataOut_0->pushPacket(I_out_0, Q_out_0, *metadata); |
|---|
| 440 | dataOut_0->pushPacket(I_out_0, Q_out_0); |
|---|
| 441 | j=0; |
|---|
| 442 | } |
|---|
| 443 | } |
|---|
| 444 | |
|---|
| 445 | // ASSEMBLE_EOM_CODE: |
|---|
| 446 | // push phasing pattern |
|---|
| 447 | ///\todo push control packet (BPSK) |
|---|
| 448 | if (frameType != FRAME_TYPE_CONTROL) { |
|---|
| 449 | // No need to push additional control information as internal frame data |
|---|
| 450 | // are already control |
|---|
| 451 | DEBUG(7, FrameAssembler_metadata, "pushing control " << I_out_control.length() << " frame samples") |
|---|
| 452 | //HV metadata->port_id = 1;//127; |
|---|
| 453 | //dataOut_0->pushPacket(I_out_control, Q_out_control, *metadata); |
|---|
| 454 | //HV no EOM dataOut_0->pushPacket(I_out_control, Q_out_control); |
|---|
| 455 | //HV metadata->port_id = 0; |
|---|
| 456 | } |
|---|
| 457 | |
|---|
| 458 | // push ramp-down phasing pattern |
|---|
| 459 | DEBUG(7, FrameAssembler_metadata, "pushing ramp down phasing " << I_out_ramp_up.length() << " frame samples") |
|---|
| 460 | // dataOut_0->pushPacket(I_out_ramp_down, Q_out_ramp_down, *metadata); |
|---|
| 461 | dataOut_0->pushPacket(I_out_ramp_down, Q_out_ramp_down); |
|---|
| 462 | |
|---|
| 463 | if (ossieDebugLevel >= 4) { |
|---|
| 464 | std::cout << "Frame count: " |
|---|
| 465 | << "app_1(" << num_frames_sent_app_1 << ") " |
|---|
| 466 | << "app_2(" << num_frames_sent_app_2 << ") " |
|---|
| 467 | << "app_5(" << num_frames_sent_app_5 << ") " |
|---|
| 468 | << "app_6(" << num_frames_sent_app_6 << ") " |
|---|
| 469 | << "total: " << num_frames_sent_app_1+num_frames_sent_app_2 |
|---|
| 470 | << std::endl; |
|---|
| 471 | } |
|---|
| 472 | } |
|---|
| 473 | |
|---|
| 474 | delete [] I_header; |
|---|
| 475 | delete [] Q_header; |
|---|
| 476 | } |
|---|
| 477 | |
|---|
| 478 | |
|---|