Changeset 4230

Show
Ignore:
Timestamp:
06/28/07 11:26:13 (6 years ago)
Author:
DrewCormier
Message:

code now works without latency problems. data gets storred in a big matrix, then written to file at the end

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • components/FileOutput/branches/write_single_file/FileOutput.cpp

    r4228 r4230  
    3030 
    3131#include "FileOutput.h" 
     32 
     33 
     34 
     35short Ibuf[8000][8192]; 
     36short Qbuf[8000][8192]; 
     37 
     38 
    3239 
    3340FileOutput_i::FileOutput_i(const char *uuid, omni_condition *condition) : Resource_impl(uuid), component_running(condition)  
     
    132139} 
    133140 
     141static void write_data_bmlarc(std::ofstream  *fname) 
     142{ 
     143    for(unsigned int j(0);j<8000;++j) { 
     144 
     145        for (unsigned int i(0); i < 8192; ++i) { 
     146                (*fname) << Ibuf[j][i] << " " << Qbuf[j][i] << std::endl; 
     147        } 
     148    } 
     149} 
     150 
     151static void buf_data(PortTypes::ShortSequence &I_in, PortTypes::ShortSequence &Q_in) 
     152{ 
     153    static int Nrecords=0; 
     154 
     155    for (unsigned int i(0); i < I_in.length(); ++i) { 
     156        //(*fname) << I_in[i] << " " << Q_in[i] << std::endl; 
     157        Ibuf[Nrecords][i]=I_in[i];  
     158        Qbuf[Nrecords][i]=Q_in[i];  
     159   } 
     160   Nrecords++; 
     161} 
     162 
    134163 
    135164void FileOutput_i::process_data() 
     
    138167 
    139168    PortTypes::ShortSequence *I_in(NULL), *Q_in(NULL); 
     169 
     170    //PortTypes::ShortSequence  
     171  
     172    //static short Ibuf[8000][8192]; 
     173    //static short Qbuf[8000][8192]; 
     174 
    140175    unsigned int len(0); 
    141176    unsigned int numberEvents(0);  // count the number of packets that have been written 
    142     unsigned int maxEvents(1000);  // number of packets to write (1 second of ATSC data? 
     177    unsigned int maxEvents(8000);  // number of packets to write (1 second of ATSC data? 
    143178    std::ofstream *outFile(NULL); 
    144179 
     
    149184        len = I_in->length(); 
    150185 
    151         if (numberEvents >= NumberFiles) { 
    152             dataIn_0->bufferEmptied(); 
    153             continue; 
    154         } 
    155         
    156         // Handle file state 
    157         if (numberEvents <= maxEvents){  
    158                 if (numberEvents == 0) {// First packet: Open file and write data 
    159                         numberEvents++; 
    160                         std::ostringstream fname; 
     186        //std::cout << numberEvents << std::endl; 
     187 
     188        if (numberEvents <= maxEvents){ 
     189                if (numberEvents < maxEvents) { // Write data 
     190                        //write_data(outFile, *I_in, *Q_in); 
     191                        buf_data(*I_in,*Q_in); 
     192                        numberEvents++; 
     193 
     194                } else if (numberEvents == maxEvents) {  //last desired packet 
     195                        std::ostringstream fname; 
    161196                        fname << FileName << numberEvents << ".dat";  
    162197                        outFile = new std::ofstream(fname.str().c_str()); 
    163198 
    164                         write_data(outFile, *I_in, *Q_in); 
    165  
    166                 } else if (numberEvents < maxEvents) { // Write data 
    167                         write_data(outFile, *I_in, *Q_in); 
     199                        //write_data(outFile, *I_in, *Q_in); 
     200                        //buf_data(*I_in,*Q_in); 
     201 
    168202                        numberEvents++; 
    169  
    170                 } else if (numberEvents == maxEvents) {  //last desired packet 
    171                         numberEvents++; 
    172                         write_data(outFile, *I_in, *Q_in); 
     203                        write_data_bmlarc(outFile); 
    173204                            delete(outFile); 
    174205                } 
    175206         
    176207        } else { 
     208 
    177209                std::cout << "done writing data \n" ; 
    178                 sleep(20); 
     210                //sleep(20); 
    179211        } 
    180212