Changeset 4230
- Timestamp:
- 06/28/07 11:26:13 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
components/FileOutput/branches/write_single_file/FileOutput.cpp
r4228 r4230 30 30 31 31 #include "FileOutput.h" 32 33 34 35 short Ibuf[8000][8192]; 36 short Qbuf[8000][8192]; 37 38 32 39 33 40 FileOutput_i::FileOutput_i(const char *uuid, omni_condition *condition) : Resource_impl(uuid), component_running(condition) … … 132 139 } 133 140 141 static 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 151 static 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 134 163 135 164 void FileOutput_i::process_data() … … 138 167 139 168 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 140 175 unsigned int len(0); 141 176 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? 143 178 std::ofstream *outFile(NULL); 144 179 … … 149 184 len = I_in->length(); 150 185 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; 161 196 fname << FileName << numberEvents << ".dat"; 162 197 outFile = new std::ofstream(fname.str().c_str()); 163 198 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 168 202 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); 173 204 delete(outFile); 174 205 } 175 206 176 207 } else { 208 177 209 std::cout << "done writing data \n" ; 178 sleep(20);210 //sleep(20); 179 211 } 180 212