Changeset 2301
- Timestamp:
- 12/01/06 13:38:37 (6 years ago)
- Location:
- components/FileOutput/trunk/FileOutput
- Files:
-
- 3 modified
-
FileOutput.cpp (modified) (2 diffs)
-
FileOutput.h (modified) (1 diff)
-
FileOutput.prf.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
components/FileOutput/trunk/FileOutput/FileOutput.cpp
r2298 r2301 24 24 #include <string> 25 25 #include <iostream> 26 #include <sstream> 27 #include <fstream> 28 26 29 #include "FileOutput.h" 27 30 … … 119 122 } 120 123 124 static void write_data(std::ofstream *fname, PortTypes::ShortSequence &I_in, PortTypes::ShortSequence &Q_in) 125 { 126 127 for (unsigned int i(0); i < I_in.length(); ++i) { 128 (*fname) << I_in[i] << " " << Q_in[i] << std::endl; 129 } 130 } 131 132 121 133 void FileOutput_i::process_data() 122 134 { 123 135 std::cout << "FileOutput's process_data thread started" << std::endl; 124 136 137 PortTypes::ShortSequence *I_in(NULL), *Q_in(NULL); 138 unsigned int len(0); 139 bool trigger(false), last_trigger(false); 140 unsigned int numberEvents(0); 141 std::ofstream *outFile(NULL); 125 142 126 143 127 PortTypes::ShortSequence *I_in_0(NULL), *Q_in_0(NULL);128 CORBA::UShort I_in_0_length, Q_in_0_length;144 while(1) { 145 dataIn_0->getData(I_in, Q_in); 129 146 130 while(1) 131 { 132 dataIn_0->getData(I_in_0, Q_in_0); 147 len = I_in->length(); 133 148 134 I_in_0_length = I_in_0->length(); 135 Q_in_0_length = Q_in_0->length(); 149 if (numberEvents > NumberFiles) { 150 dataIn_0->bufferEmptied(); 151 continue; 152 } 136 153 137 /*insert code here to do work*/ 154 // calculate energy 155 unsigned int energy(0); 156 for (unsigned int i(0); i < len; ++i) { 157 if (abs((*I_in)[i]) > abs((*Q_in)[i])) 158 energy += (*I_in)[i]; 159 else 160 energy += (*Q_in)[i]; 161 } 162 energy /= len; 138 163 164 // Do we write data? 165 if (energy > TriggerThreshold) 166 trigger = true; 167 else 168 trigger = false; 139 169 170 // Handle file state 171 if (trigger == true && last_trigger == false) {// Open file and write data 172 numberEvents++; 173 std::ostringstream fname; 174 fname << FileName << numberEvents << ".dat"; 175 outFile = new std::ofstream(fname.str().c_str()); 140 176 141 142 177 write_data(outFile, *I_in, *Q_in); 178 } else if (trigger == true && last_trigger == true) { // Write data 179 write_data(outFile, *I_in, *Q_in); 180 } else if (trigger == false && last_trigger == true) { // Write data and close 181 write_data(outFile, *I_in, *Q_in); 182 delete(outFile); 183 } 184 last_trigger = trigger; 143 185 144 186 dataIn_0->bufferEmptied(); -
components/FileOutput/trunk/FileOutput/FileOutput.h
r2298 r2301 69 69 70 70 std::string FileName; 71 short TriggerThreshold;72 short NumberFiles;71 unsigned short TriggerThreshold; 72 unsigned short NumberFiles; 73 73 std::string FileFormat; 74 74 -
components/FileOutput/trunk/FileOutput/FileOutput.prf.xml
r2296 r2301 6 6 <simple type="string" id="DCE:c2654772-ac2c-42be-8f0b-d6c7a4b0fa49" name="FileName" mode="readonly"> 7 7 <description>File Name for output data</description> 8 <value>myData .dat</value>8 <value>myData</value> 9 9 <kind kindtype="configure"/> 10 10 </simple>