Line data Source code
1 : #include <alma/ASDMBinaries/SDMDataObjectWriter.h>
2 : #include <algorithm>
3 :
4 : #include <alma/ASDMBinaries/CommonDefines.h>
5 :
6 : using namespace AxisNameMod;
7 : using namespace BasebandNameMod;
8 : using namespace CorrelationModeMod;
9 : using namespace CorrelatorTypeMod;
10 : using namespace NetSidebandMod;
11 : using namespace PrimitiveDataTypeMod;
12 : using namespace ProcessorTypeMod;
13 : using namespace SpectralResolutionTypeMod;
14 : using namespace StokesParameterMod;
15 :
16 : using namespace std;
17 :
18 : namespace asdmbinaries {
19 :
20 : const string SDMDataObjectWriter::MIMEBOUNDARY_1 = $MIMEBOUNDARY1;
21 : const string SDMDataObjectWriter::MIMEBOUNDARY_2 = $MIMEBOUNDARY2;
22 :
23 : vector<AxisName> SDMDataObjectWriter::WVRDATAAXES;
24 : vector<AxisName> SDMDataObjectWriter::WVRDATAFLAGSAXES;
25 :
26 : const bool SDMDataObjectWriter::initClass_ = SDMDataObjectWriter::initClass();
27 :
28 0 : SDMDataObjectWriter::SDMDataObjectWriter(const string& uid, const string& title) {
29 0 : currentState_ = START;
30 0 : otype_ = STDOUT;
31 0 : uid_ = uid;
32 0 : title_ = title;
33 0 : preamble();
34 0 : done_ = false;
35 0 : sdmDataSubsetNum_ = 0;
36 0 : numBytes_ = 0;
37 :
38 0 : sdmDataObject_.schemaVersion_ = SCHEMAVERSION;
39 0 : sdmDataObject_.byteOrder_ = ByteOrder::Machine_Endianity;
40 0 : }
41 :
42 0 : SDMDataObjectWriter::SDMDataObjectWriter(ostringstream* oss, const string& uid, const string& title) {
43 0 : currentState_ = START;
44 0 : otype_ = MEMORY;
45 0 : ofs_ = 0;
46 0 : oss_ = oss;
47 0 : uid_ = uid;
48 0 : title_ = title;
49 0 : preamble();
50 0 : done_ = false;
51 0 : sdmDataSubsetNum_ = 0;
52 0 : numBytes_ = 0;
53 :
54 0 : sdmDataObject_.schemaVersion_ = SCHEMAVERSION;
55 0 : sdmDataObject_.byteOrder_ = ByteOrder::Machine_Endianity;
56 0 : }
57 :
58 536 : SDMDataObjectWriter::SDMDataObjectWriter(ofstream* ofs, const string& uid, const string& title) {
59 536 : currentState_ = START;
60 536 : otype_ = FILE;
61 536 : ofs_ = ofs;
62 536 : oss_ = 0;
63 536 : uid_ = uid;
64 536 : title_ = title;
65 536 : preamble();
66 536 : done_ = false;
67 536 : sdmDataSubsetNum_ = 0;
68 536 : numBytes_ = 0;
69 :
70 536 : sdmDataObject_.schemaVersion_ = SCHEMAVERSION;
71 536 : sdmDataObject_.byteOrder_ = ByteOrder::Machine_Endianity;
72 536 : }
73 :
74 536 : SDMDataObjectWriter::~SDMDataObjectWriter() {
75 : // Do nothing actually !
76 : // if (!done_) done();
77 536 : }
78 :
79 536 : void SDMDataObjectWriter::done() {
80 536 : checkState(T_DONE, "done");
81 :
82 : // Write MIME postamble.
83 536 : postamble();
84 :
85 : // And do some I/O management.
86 536 : switch (otype_) {
87 0 : case STDOUT:
88 : // Do Nothing special
89 0 : break;
90 0 : case MEMORY:
91 : // Do Nothing special
92 0 : break;
93 536 : case FILE:
94 : // Do nothing special
95 536 : break;
96 : }
97 536 : numBytes_ = 0;
98 536 : done_ = true;
99 536 : }
100 :
101 185540 : void SDMDataObjectWriter::output(const string& s) {
102 185540 : numBytes_ += (uint64_t) s.size();
103 185540 : switch (otype_) {
104 0 : case STDOUT:
105 0 : cout << s;
106 0 : break;
107 :
108 0 : case MEMORY:
109 0 : *oss_ << s;
110 0 : break;
111 :
112 185540 : case FILE:
113 185540 : *ofs_ << s;
114 185540 : break;
115 : }
116 185540 : }
117 :
118 77880 : void SDMDataObjectWriter::outputln(const string& s) {
119 77880 : output(s);
120 77880 : outputln();
121 77880 : }
122 :
123 0 : void SDMDataObjectWriter::output(const float* data, uint32_t numData) {
124 0 : switch (otype_) {
125 :
126 0 : case STDOUT:
127 0 : cout.write((const char*)data, numData*sizeof(float));
128 0 : break;
129 :
130 0 : case MEMORY:
131 0 : oss_->write((const char*)data, numData*sizeof(float));
132 0 : break;
133 :
134 0 : case FILE:
135 0 : ofs_->write((const char*)data, numData*sizeof(float));
136 0 : break;
137 : }
138 0 : }
139 :
140 0 : void SDMDataObjectWriter::outputln(const float* data, uint32_t numData) {
141 0 : output(data, numData);
142 0 : outputln();
143 0 : }
144 :
145 107660 : void SDMDataObjectWriter::outputln() {
146 107660 : output("\n");
147 107660 : }
148 :
149 12088 : void SDMDataObjectWriter::outputlnLocation(const string& name, const SDMDataSubset& sdmDataSubset) {
150 12088 : outputln("Content-Location: " + sdmDataSubset.projectPath() + name + ".bin");
151 12088 : }
152 :
153 536 : void SDMDataObjectWriter::preamble() {
154 536 : outputln("MIME-Version: 1.0");
155 536 : outputln("Content-Type: multipart/mixed; boundary=\""+MIMEBOUNDARY_1+"\"; type=\"text/xml\"");
156 536 : outputln("Content-Description: " + title_ );
157 536 : outputln("Content-Location: uid:" + uid_.substr(4));
158 536 : outputln();
159 536 : }
160 :
161 :
162 536 : void SDMDataObjectWriter::postamble() {
163 536 : outputln("--"+MIMEBOUNDARY_1+"--");
164 536 : }
165 :
166 :
167 :
168 : // void SDMDataObjectWriter::addTPSubscan(uint64_t time,
169 : // uint64_t interval,
170 : // const vector<FLAGSTYPE>& flags,
171 : // const vector<ACTUALTIMESTYPE>& actualTimes,
172 : // const vector<ACTUALDURATIONSTYPE>& actualDurations,
173 : // const vector<AUTODATATYPE>& autoData){
174 : // checkState(T_ADDTPSUBSCAN, "addTPSubscan");
175 : // outputln("Content-Type: Multipart/Related; boundary=\""+MIMEBOUNDARY_2+"\";type=\"text/xml\"; start=\"<DataSubset.xml>\"");
176 : // outputln("Content-Description: Data and metadata subset");
177 : // outputln("--"+MIMEBOUNDARY_2);
178 : // outputln("Content-Type: text/xml; charset=\"UTF-8\"");
179 : // outputln("Content-Location: " + sdmDataObject_.projectPath() + "desc.xml");
180 : // outputln();
181 :
182 : // SDMDataSubset tpDataSubset(&sdmDataObject_,
183 : // time,
184 : // interval,
185 : // autoData);
186 :
187 : // tpDataSubset.flags_ = (tpDataSubset.nFlags_ = flags.size()) ? &tpDataSubset.flags_[0] : 0;
188 : // tpDataSubset.actualTimes_ = (tpDataSubset.nActualTimes_ = actualTimes.size()) ? &tpDataSubset.actualTimes_[0] : 0;
189 : // tpDataSubset.actualDurations_ = (tpDataSubset.nActualDurations_ = actualDurations.size()) ? &tpDataSubset.actualDurations_[0] : 0;
190 : // outputln(tpDataSubset.toXML());
191 : // //outputln();
192 :
193 : // if (flags.size() != 0) {
194 : // uint32_t numFlags = sdmDataObject_.dataStruct_.flags_.size();
195 : // if (numFlags!=0 && numFlags != flags.size()) {
196 : // ostringstream oss;
197 : // oss << "The number of values provided for 'flags' ("
198 : // << flags.size()
199 : // << "), is not equal to the number declared in the global header ("
200 : // << numFlags << ").";
201 : // throw SDMDataObjectWriterException(oss.str());
202 : // }
203 : // outputln("--"+MIMEBOUNDARY_2);
204 : // outputln("Content-Type: binary/octet-stream");
205 : // outputln("Content-Location: " + tpDataSubset.projectPath() + "flags.bin");
206 : // outputln();
207 : // outputln<uint32_t>(flags);
208 : // }
209 :
210 : // if (actualTimes.size() != 0) {
211 : // uint32_t numActualTimes = sdmDataObject_.dataStruct_.actualTimes_.size();
212 : // if (numActualTimes != 0 && numActualTimes != actualTimes.size()) {
213 : // ostringstream oss;
214 : // oss << "The number of values provided for 'actualTimes' ("
215 : // << actualTimes.size()
216 : // << "), is not equal to the number declared in the global header ("
217 : // << numActualTimes << ").";
218 : // throw SDMDataObjectWriterException(oss.str());
219 : // }
220 : // outputln("--"+MIMEBOUNDARY_2);
221 : // outputln("Content-Type: binary/octet-stream");
222 : // outputln("Content-Location: " + tpDataSubset.projectPath() + "actualTimes.bin");
223 :
224 : // outputln();
225 : // outputln<ACTUALTIMESTYPE>(actualTimes);
226 : // }
227 :
228 : // if (actualDurations.size() != 0) {
229 : // uint32_t numActualDurations = sdmDataObject_.dataStruct_.actualDurations_.size();
230 : // if (numActualDurations != 0 && numActualDurations != actualDurations.size()) {
231 : // ostringstream oss;
232 : // oss << "The number of values provided for 'actualDurations' ("
233 : // << actualDurations.size()
234 : // << "), is not equal to the number declared in the global header ("
235 : // << numActualDurations << ").";
236 : // throw SDMDataObjectWriterException(oss.str());
237 : // }
238 : // outputln("--"+MIMEBOUNDARY_2);
239 : // outputln("Content-Type: binary/octet-stream");
240 : // outputln("Content-Location: " + tpDataSubset.projectPath() + "actualDurations.bin");
241 : // outputln();
242 : // outputln<ACTUALDURATIONSTYPE>(actualDurations);
243 : // }
244 :
245 : // uint32_t numAutoData = sdmDataObject_.dataStruct_.autoData_.size();
246 : // if (numAutoData != 0 && numAutoData != autoData.size()) {
247 : // ostringstream oss;
248 : // oss << "The number of values provided for 'autoData' ("
249 : // << autoData.size()
250 : // << "), is not equal to the number declared in the global header ("
251 : // << numAutoData << ").";
252 : // throw SDMDataObjectWriterException(oss.str());
253 : // }
254 : // outputln("--"+MIMEBOUNDARY_2);
255 : // outputln("Content-Type: binary/octet-stream");
256 : // outputln("Content-Location: " + tpDataSubset.projectPath() + "autoData.bin");
257 : // outputln();
258 : // outputln<float>(autoData);
259 : // outputln("--"+MIMEBOUNDARY_2+"--");
260 : // }
261 :
262 0 : void SDMDataObjectWriter::tpData(uint64_t startTime,
263 : const string& execBlockUID,
264 : uint32_t execBlockNum,
265 : uint32_t scanNum,
266 : uint32_t subscanNum,
267 : uint32_t numberOfIntegrations,
268 : uint32_t numAntenna,
269 : const vector<SDMDataObject::Baseband>& basebands,
270 : uint64_t time,
271 : uint64_t interval,
272 : const vector<AxisName>& autoDataAxes,
273 : const vector<AUTODATATYPE>& autoData) {
274 0 : checkState(T_TPDATA, "tpData");
275 :
276 0 : SDMDataObject::DataStruct dataStruct;
277 0 : dataStruct.basebands_ = basebands;
278 0 : dataStruct.autoData_ = SDMDataObject::AutoDataBinaryPart(autoData.size(), autoDataAxes, false);
279 :
280 0 : sdmDataObject_.valid_ = true;
281 :
282 0 : sdmDataObject_.startTime_ = startTime;
283 0 : sdmDataObject_.dataOID_ = uid_;
284 0 : sdmDataObject_.title_ = title_;
285 0 : sdmDataObject_.dimensionality_ = 0;
286 0 : sdmDataObject_.numTime_ = numberOfIntegrations;
287 0 : sdmDataObject_.execBlockUID_ = execBlockUID;
288 0 : sdmDataObject_.execBlockNum_ = execBlockNum;
289 0 : sdmDataObject_.scanNum_ = scanNum;
290 0 : sdmDataObject_.subscanNum_ = subscanNum;
291 0 : sdmDataObject_.numAntenna_ = numAntenna;
292 0 : sdmDataObject_.correlationMode_ = AUTO_ONLY;
293 0 : sdmDataObject_.spectralResolutionType_ = BASEBAND_WIDE;
294 0 : sdmDataObject_.processorType_ = RADIOMETER;
295 0 : sdmDataObject_.dataStruct_ = dataStruct;
296 :
297 0 : outputln("--"+MIMEBOUNDARY_1);
298 0 : outputln("Content-Type: text/xml; charset=\"UTF-8\"");
299 0 : outputln("Content-Transfer-Encoding: 8bit");
300 0 : outputln("Content-Location: " + sdmDataObject_.projectPath() + "desc.xml");
301 0 : outputln();
302 :
303 0 : outputln(sdmDataObject_.toXML());
304 0 : outputln("--"+MIMEBOUNDARY_1);
305 0 : outputln("Content-Type: Multipart/Related; boundary=\""+MIMEBOUNDARY_2+"\";type=\"text/xml\"; start=\"<DataSubset.xml>\"");
306 0 : outputln("Content-Description: Data and metadata subset");
307 0 : outputln("--"+MIMEBOUNDARY_2);
308 0 : outputln("Content-Type: text/xml; charset=\"UTF-8\"");
309 0 : outputln("Content-Location: " + sdmDataObject_.projectPath() + "desc.xml");
310 0 : outputln();
311 :
312 : SDMDataSubset tpDataSubset(&sdmDataObject_,
313 : time,
314 : interval,
315 0 : autoData);
316 0 : outputln(tpDataSubset.toXML());
317 : //outputln();
318 :
319 0 : outputln("--"+MIMEBOUNDARY_2);
320 0 : outputln("Content-Type: binary/octet-stream");
321 0 : outputln("Content-Location: " + tpDataSubset.projectPath() + "autoData.bin");
322 0 : outputln();
323 :
324 0 : outputln<float>(autoData);
325 0 : outputln("--"+MIMEBOUNDARY_2+"--");
326 0 : }
327 :
328 0 : void SDMDataObjectWriter::tpData(uint64_t startTime,
329 : const string& execBlockUID,
330 : uint32_t execBlockNum,
331 : uint32_t scanNum,
332 : uint32_t subscanNum,
333 : uint32_t numberOfIntegrations,
334 : uint32_t numAntenna,
335 :
336 : const vector<SDMDataObject::Baseband>& basebands,
337 :
338 : uint64_t time,
339 : uint64_t interval,
340 :
341 : const vector<AxisName>& flagsAxes,
342 : const vector<FLAGSTYPE>& flags,
343 : const vector<AxisName>& actualTimesAxes,
344 : const vector<ACTUALTIMESTYPE>& actualTimes,
345 : const vector<AxisName>& actualDurationsAxes,
346 : const vector<ACTUALDURATIONSTYPE>& actualDurations,
347 : const vector<AxisName>& autoDataAxes,
348 : const vector<AUTODATATYPE>& autoData) {
349 0 : checkState(T_TPDATA, "tpData");
350 :
351 0 : SDMDataObject::DataStruct dataStruct;
352 0 : dataStruct.basebands_ = basebands;
353 0 : if (flags.size()) dataStruct.flags_ = SDMDataObject::BinaryPart(flags.size(), flagsAxes);
354 0 : if (actualTimes.size()) dataStruct.actualTimes_ = SDMDataObject::BinaryPart(actualTimes.size(), actualTimesAxes);
355 0 : if (actualDurations.size()) dataStruct.actualDurations_ = SDMDataObject::BinaryPart(actualDurations.size(), actualDurationsAxes);
356 0 : dataStruct.autoData_ = SDMDataObject::AutoDataBinaryPart(autoData.size(), autoDataAxes, false);
357 :
358 0 : sdmDataObject_.valid_ = true;
359 :
360 0 : sdmDataObject_.startTime_ = startTime;
361 0 : sdmDataObject_.dataOID_ = uid_;
362 0 : sdmDataObject_.title_ = title_;
363 0 : sdmDataObject_.dimensionality_ = 0;
364 0 : sdmDataObject_.numTime_ = numberOfIntegrations;
365 0 : sdmDataObject_.execBlockUID_ = execBlockUID;
366 0 : sdmDataObject_.execBlockNum_ = execBlockNum;
367 0 : sdmDataObject_.scanNum_ = scanNum;
368 0 : sdmDataObject_.subscanNum_ = subscanNum;
369 0 : sdmDataObject_.numAntenna_ = numAntenna;
370 0 : sdmDataObject_.correlationMode_ = AUTO_ONLY;
371 0 : sdmDataObject_.spectralResolutionType_ = BASEBAND_WIDE;
372 0 : sdmDataObject_.processorType_ = RADIOMETER;
373 0 : sdmDataObject_.dataStruct_ = dataStruct;
374 :
375 0 : outputln("--"+MIMEBOUNDARY_1);
376 0 : outputln("Content-Type: text/xml; charset=\"UTF-8\"");
377 0 : outputln("Content-Transfer-Encoding: 8bit");
378 0 : outputln("Content-Location: " + sdmDataObject_.projectPath() + "desc.xml");
379 0 : outputln();
380 :
381 0 : outputln(sdmDataObject_.toXML());
382 0 : outputln("--"+MIMEBOUNDARY_1);
383 0 : outputln("Content-Type: Multipart/Related; boundary=\""+MIMEBOUNDARY_2+"\";type=\"text/xml\"; start=\"<DataSubset.xml>\"");
384 0 : outputln("Content-Description: Data and metadata subset");
385 0 : outputln("--"+MIMEBOUNDARY_2);
386 0 : outputln("Content-Type: text/xml; charset=\"UTF-8\"");
387 0 : outputln("Content-Location: " + sdmDataObject_.projectPath() + "desc.xml");
388 0 : outputln();
389 :
390 : SDMDataSubset tpDataSubset(&sdmDataObject_,
391 : time,
392 : interval,
393 0 : autoData);
394 :
395 0 : tpDataSubset.flags_ = (tpDataSubset.nFlags_ = flags.size()) ? &tpDataSubset.flags_[0] : 0;
396 0 : tpDataSubset.actualTimes_ = (tpDataSubset.nActualTimes_ = actualTimes.size()) ? &tpDataSubset.actualTimes_[0] : 0;
397 0 : tpDataSubset.actualDurations_ = (tpDataSubset.nActualDurations_ = actualDurations.size()) ? &tpDataSubset.actualDurations_[0] : 0;
398 0 : outputln(tpDataSubset.toXML());
399 : //outputln();
400 :
401 :
402 :
403 0 : if (flags.size() != 0) {
404 0 : uint32_t numFlags = sdmDataObject_.dataStruct_.flags_.size();
405 0 : if (numFlags!=0 && numFlags != flags.size()) {
406 0 : ostringstream oss;
407 0 : oss << "The number of values provided for 'flags' ("
408 0 : << flags.size()
409 0 : << "), is not equal to the number declared in the global header ("
410 0 : << numFlags << ").";
411 0 : throw SDMDataObjectWriterException(oss.str());
412 0 : }
413 0 : outputln("--"+MIMEBOUNDARY_2);
414 0 : outputln("Content-Type: binary/octet-stream");
415 0 : outputln("Content-Location: " + tpDataSubset.projectPath() + "flags.bin");
416 0 : outputln();
417 0 : outputln<uint32_t>(flags);
418 : }
419 :
420 0 : if (actualTimes.size() != 0) {
421 0 : uint32_t numActualTimes = sdmDataObject_.dataStruct_.actualTimes_.size();
422 0 : if (numActualTimes != 0 && numActualTimes != actualTimes.size()) {
423 0 : ostringstream oss;
424 0 : oss << "The number of values provided for 'actualTimes' ("
425 0 : << actualTimes.size()
426 0 : << "), is not equal to the number declared in the global header ("
427 0 : << numActualTimes << ").";
428 0 : throw SDMDataObjectWriterException(oss.str());
429 0 : }
430 0 : outputln("--"+MIMEBOUNDARY_2);
431 0 : outputln("Content-Type: binary/octet-stream");
432 0 : outputln("Content-Location: " + tpDataSubset.projectPath() + "actualTimes.bin");
433 :
434 0 : outputln();
435 0 : outputln<ACTUALTIMESTYPE>(actualTimes);
436 : }
437 :
438 0 : if (actualDurations.size() != 0) {
439 0 : uint32_t numActualDurations = sdmDataObject_.dataStruct_.actualDurations_.size();
440 0 : if (numActualDurations != 0 && numActualDurations != actualDurations.size()) {
441 0 : ostringstream oss;
442 0 : oss << "The number of values provided for 'actualDurations' ("
443 0 : << actualDurations.size()
444 0 : << "), is not equal to the number declared in the global header ("
445 0 : << numActualDurations << ").";
446 0 : throw SDMDataObjectWriterException(oss.str());
447 0 : }
448 0 : outputln("--"+MIMEBOUNDARY_2);
449 0 : outputln("Content-Type: binary/octet-stream");
450 0 : outputln("Content-Location: " + tpDataSubset.projectPath() + "actualDurations.bin");
451 0 : outputln();
452 0 : outputln<ACTUALDURATIONSTYPE>(actualDurations);
453 : }
454 :
455 0 : uint32_t numAutoData = sdmDataObject_.dataStruct_.autoData_.size();
456 0 : if (numAutoData != 0 && numAutoData != autoData.size()) {
457 0 : ostringstream oss;
458 0 : oss << "The number of values provided for 'autoData' ("
459 0 : << autoData.size()
460 0 : << "), is not equal to the number declared in the global header ("
461 0 : << numAutoData << ").";
462 0 : throw SDMDataObjectWriterException(oss.str());
463 0 : }
464 0 : outputln("--"+MIMEBOUNDARY_2);
465 0 : outputln("Content-Type: binary/octet-stream");
466 0 : outputln("Content-Location: " + tpDataSubset.projectPath() + "autoData.bin");
467 0 : outputln();
468 0 : outputln<float>(autoData);
469 0 : outputln("--"+MIMEBOUNDARY_2+"--");
470 0 : }
471 :
472 0 : void SDMDataObjectWriter::tpDataHeader(uint64_t startTime,
473 : const string& execBlockUID,
474 : uint32_t execBlockNum,
475 : uint32_t scanNum,
476 : uint32_t subscanNum,
477 : uint32_t numAntenna,
478 : SDMDataObject::DataStruct& dataStruct) {
479 0 : checkState(T_TPDATAHEADER, "tpDataHeader");
480 :
481 0 : sdmDataObject_.valid_ = true;
482 :
483 0 : sdmDataObject_.startTime_ = startTime;
484 0 : sdmDataObject_.dataOID_ = uid_;
485 0 : sdmDataObject_.title_ = title_;
486 0 : sdmDataObject_.dimensionality_ = 1;
487 0 : sdmDataObject_.execBlockUID_ = execBlockUID;
488 0 : sdmDataObject_.execBlockNum_ = execBlockNum;
489 0 : sdmDataObject_.scanNum_ = scanNum;
490 0 : sdmDataObject_.subscanNum_ = subscanNum;
491 0 : sdmDataObject_.numAntenna_ = numAntenna;
492 0 : sdmDataObject_.correlationMode_ = AUTO_ONLY;
493 0 : sdmDataObject_.spectralResolutionType_ = BASEBAND_WIDE;
494 0 : sdmDataObject_.processorType_ = RADIOMETER;
495 0 : sdmDataObject_.dataStruct_ = dataStruct;
496 :
497 0 : outputln("--"+MIMEBOUNDARY_1);
498 0 : outputln("Content-Type: text/xml; charset=\"UTF-8\"");
499 0 : outputln("Content-Transfer-Encoding: 8bit"); //outputln("Content-Location: " + sdmDataObject_.projectPath() + "desc.xml");
500 0 : outputln("Content-Location: sdmDataHeader.xml");
501 0 : outputln();
502 :
503 0 : outputln(sdmDataObject_.toXML());
504 0 : }
505 :
506 0 : void SDMDataObjectWriter::tpAddIntegration(uint32_t integrationNum,
507 : uint64_t time,
508 : uint64_t interval,
509 : const vector<FLAGSTYPE>& flags,
510 : const vector<ACTUALTIMESTYPE>& actualTimes,
511 : const vector<ACTUALDURATIONSTYPE>& actualDurations,
512 : const vector<AUTODATATYPE>& autoData) {
513 :
514 0 : checkState(T_ADDTPINTEGRATION, "tpAddIntegration");
515 :
516 0 : SDMDataSubset sdmDataSubset(&sdmDataObject_);
517 0 : sdmDataObject_.numTime_++;
518 0 : sdmDataSubsetNum_++;
519 :
520 : // integrationNum and subintegrationNum.
521 0 : sdmDataSubset.integrationNum_ = integrationNum;
522 0 : sdmDataSubset.subintegrationNum_ = 0;
523 :
524 : // The time.
525 0 : sdmDataSubset.time_ = time;
526 :
527 : // The interval.
528 0 : sdmDataSubset.interval_ = interval;
529 :
530 : // Attachments size;
531 0 : sdmDataSubset.nActualTimes_ = actualTimes.size();
532 0 : sdmDataSubset.nActualDurations_ = actualDurations.size();
533 0 : sdmDataSubset.nZeroLags_ = 0;
534 0 : sdmDataSubset.nCrossData_ = 0;
535 :
536 0 : sdmDataSubset.nFlags_ = flags.size();
537 :
538 0 : sdmDataSubset.nAutoData_ = autoData.size();
539 :
540 0 : outputln("--"+MIMEBOUNDARY_1);
541 0 : outputln("Content-Type: Multipart/Related; boundary=\""+MIMEBOUNDARY_2+"\";type=\"text/xml\"");
542 0 : outputln("Content-Description: Data and metadata subset");
543 0 : outputln("--"+MIMEBOUNDARY_2);
544 0 : outputln("Content-Type: text/xml; charset=\"UTF-8\"");
545 0 : outputln("Content-Location: " + sdmDataSubset.projectPath() + "desc.xml");
546 0 : outputln();
547 0 : outputln(sdmDataSubset.toXML());
548 :
549 : // Write flags, if any
550 0 : if (flags.size() != 0) {
551 0 : uint32_t numFlags = sdmDataObject_.dataStruct_.flags_.size();
552 0 : if (numFlags !=0 && numFlags != flags.size()) {
553 0 : ostringstream oss;
554 0 : oss << "The number of values provided for 'flags' ("
555 0 : << flags.size()
556 0 : << "), is not equal to the number declared in the global header ("
557 0 : << numFlags << ").";
558 0 : throw SDMDataObjectWriterException(oss.str());
559 0 : }
560 0 : outputln("--"+MIMEBOUNDARY_2);
561 0 : outputln("Content-Type: binary/octet-stream");
562 0 : outputlnLocation("flags", sdmDataSubset);
563 0 : outputln();
564 0 : outputln<uint32_t>(flags);
565 : }
566 :
567 : // Write actual times, if any
568 0 : if (actualTimes.size() != 0) {
569 0 : uint32_t numActualTimes = sdmDataObject_.dataStruct_.actualTimes_.size();
570 0 : if (numActualTimes != 0 && numActualTimes != actualTimes.size()) {
571 0 : ostringstream oss;
572 0 : oss << "The number of values provided for 'actualTimes' ("
573 0 : << actualTimes.size()
574 0 : << "), is not equal to the number declared in the global header ("
575 0 : << numActualTimes << ").";
576 0 : throw SDMDataObjectWriterException(oss.str());
577 0 : }
578 0 : outputln("--"+MIMEBOUNDARY_2);
579 0 : outputln("Content-Type: binary/octet-stream");
580 0 : outputlnLocation("actualTimes", sdmDataSubset);
581 0 : outputln();
582 0 : outputln<ACTUALTIMESTYPE>(actualTimes);
583 : }
584 :
585 : // Write actual durations, if any
586 0 : if (actualDurations.size() != 0) {
587 0 : uint32_t numActualDurations = sdmDataObject_.dataStruct_.actualDurations_.size();
588 0 : if (numActualDurations != 0 && numActualDurations != actualDurations.size()) {
589 0 : ostringstream oss;
590 0 : oss << "The number of values provided for 'actualDurations' ("
591 0 : << actualDurations.size()
592 0 : << "), is not equal to the number declared in the global header ("
593 0 : << numActualDurations << ").";
594 0 : throw SDMDataObjectWriterException(oss.str());
595 0 : }
596 0 : outputln("--"+MIMEBOUNDARY_2);
597 0 : outputln("Content-Type: binary/octet-stream");
598 0 : outputlnLocation("actualDurations", sdmDataSubset);
599 0 : outputln();
600 0 : outputln<ACTUALDURATIONSTYPE>(actualDurations);
601 : }
602 :
603 : // Write auto data
604 0 : uint32_t numAutoData = sdmDataObject_.dataStruct_.autoData_.size();
605 0 : if (numAutoData != autoData.size()) {
606 0 : ostringstream oss;
607 0 : oss << "The number of values provided for 'autoData' ("
608 0 : << autoData.size()
609 0 : << "), is not equal to the number declared in the global header ("
610 0 : << numAutoData << ").";
611 0 : throw SDMDataObjectWriterException(oss.str());
612 0 : }
613 0 : outputln("--"+MIMEBOUNDARY_2);
614 0 : outputln("Content-Type: binary/octet-stream");
615 0 : outputlnLocation("autoData", sdmDataSubset);
616 0 : outputln();
617 0 : outputln<float>(autoData);
618 :
619 0 : outputln("--"+MIMEBOUNDARY_2+"--");
620 0 : }
621 :
622 :
623 0 : void SDMDataObjectWriter::wvrData (const string & execBlockUID,
624 : uint32_t execBlockNum,
625 : uint32_t scanNum,
626 : uint32_t subscanNum,
627 : uint32_t numTimes,
628 : uint32_t numAntennas,
629 : uint32_t numChannels,
630 : NetSideband netSideband,
631 : uint64_t time,
632 : uint64_t interval,
633 : const vector<float>& wvrData,
634 : const vector<uint32_t>& flags) {
635 0 : checkState(T_WVRDATA, "wvrData");
636 :
637 : //
638 : //
639 : // Check situations which raise exceptions.
640 : //
641 0 : ostringstream oss;
642 0 : if (numTimes == 0 || numAntennas == 0 || numChannels == 0) {
643 0 : oss << "At least one of these arguments is nul : numTimes (" << numTimes << "), "
644 0 : << "numAntennas (" << numAntennas << "'), "
645 0 : << "numChannels (" << numChannels << "')."
646 0 : << endl;
647 0 : throw SDMDataObjectWriterException(oss.str());
648 : }
649 :
650 0 : if (wvrData.size() != numTimes * numAntennas * numChannels) {
651 0 : oss << "The size of 'wvrData' is " << wvrData.size()
652 0 : << ". It is expected to be " << numTimes * numAntennas * numChannels
653 0 : << "." << endl;
654 0 : throw SDMDataObjectWriterException(oss.str());
655 : }
656 :
657 0 : if (flags.size() !=0 && flags.size() != numTimes * numAntennas) {
658 0 : oss << "The size of 'flags' is " << flags.size()
659 0 : << ". It is expected to be wether null or equal to "
660 0 : << numTimes * numAntennas << endl;
661 0 : throw SDMDataObjectWriterException(oss.str());
662 : }
663 :
664 : //
665 : // Prepare the embedded SDMDataObject Main header
666 : //
667 0 : vector<StokesParameter> sdPolProducts(1, I);
668 0 : vector<SDMDataObject::SpectralWindow> spectralWindows(1, SDMDataObject::SpectralWindow(sdPolProducts, numChannels, 1, netSideband));
669 0 : vector<SDMDataObject::Baseband> baseBands(1, SDMDataObject::Baseband(NOBB, spectralWindows));
670 :
671 0 : sdmDataObject_.valid_ = true;
672 0 : sdmDataObject_.startTime_ = time - interval / 2;
673 0 : sdmDataObject_.dataOID_ = uid_;
674 0 : sdmDataObject_.title_ = title_;
675 0 : sdmDataObject_.dimensionality_ = 0;
676 0 : sdmDataObject_.numTime_ = numTimes;
677 0 : sdmDataObject_.execBlockUID_ = execBlockUID;
678 0 : sdmDataObject_.execBlockNum_ = execBlockNum;
679 0 : sdmDataObject_.scanNum_ = scanNum;
680 0 : sdmDataObject_.subscanNum_ = subscanNum;
681 0 : sdmDataObject_.numAntenna_ = numAntennas;
682 0 : sdmDataObject_.correlationMode_ = AUTO_ONLY;
683 0 : sdmDataObject_.spectralResolutionType_ = FULL_RESOLUTION;
684 0 : sdmDataObject_.processorType_ = RADIOMETER;
685 0 : sdmDataObject_.dataStruct_.basebands_ = baseBands;
686 0 : sdmDataObject_.dataStruct_.autoData_ = SDMDataObject::AutoDataBinaryPart(wvrData.size(), WVRDATAAXES, true);
687 0 : if (flags.size()) sdmDataObject_.dataStruct_.flags_ = SDMDataObject::BinaryPart(flags.size(), WVRDATAFLAGSAXES);
688 :
689 : //
690 : // And output it.
691 0 : outputln("--"+MIMEBOUNDARY_1);
692 0 : outputln("Content-Type: text/xml; charset=\"UTF-8\"");
693 0 : outputln("Content-Transfer-Encoding: 8bit");
694 0 : outputln("Content-Location: " + sdmDataObject_.projectPath() + "desc.xml");
695 0 : outputln();
696 :
697 0 : outputln(sdmDataObject_.toXML());
698 0 : outputln("--"+MIMEBOUNDARY_1);
699 0 : outputln("Content-Type: Multipart/Related; boundary=\""+MIMEBOUNDARY_2+"\";type=\"text/xml\"; start=\"<DataSubset.xml>\"");
700 0 : outputln("Content-Description: Data and metadata subset");
701 0 : outputln("--"+MIMEBOUNDARY_2);
702 0 : outputln("Content-Type: text/xml; charset=\"UTF-8\"");
703 0 : outputln("Content-Location: " + sdmDataObject_.projectPath() + "desc.xml");
704 0 : outputln();
705 :
706 : //
707 : //
708 : // Prepare the unique SDMDataSubset
709 : //
710 : SDMDataSubset wvrDataSubset(&sdmDataObject_,
711 : time,
712 : interval,
713 0 : wvrData);
714 0 : wvrDataSubset.flags_ = (wvrDataSubset.nFlags_ = flags.size()) ? &wvrDataSubset.flags_[0] : 0;
715 :
716 : //
717 : // And output it.
718 : //
719 0 : outputln(wvrDataSubset.toXML());
720 :
721 0 : if (flags.size() != 0) {
722 0 : outputln("--"+MIMEBOUNDARY_2);
723 0 : outputln("Content-Type: binary/octet-stream");
724 0 : outputln("Content-Location: " + wvrDataSubset.projectPath() + "flags.bin");
725 0 : outputln();
726 0 : outputln<uint32_t>(flags);
727 : }
728 :
729 0 : outputln("--"+MIMEBOUNDARY_2);
730 0 : outputln("Content-Type: binary/octet-stream");
731 0 : outputln("Content-Location: " + wvrDataSubset.projectPath() + "autoData.bin");
732 0 : outputln();
733 :
734 0 : outputln<float>(wvrData);
735 0 : outputln("--"+MIMEBOUNDARY_2+"--");
736 0 : }
737 :
738 :
739 : /**
740 : * Writes the XML global header into its attachment on the MIME message stream.
741 : */
742 536 : void SDMDataObjectWriter::corrDataHeader(uint64_t startTime,
743 : const string& execBlockUID,
744 : uint32_t execBlockNum,
745 : uint32_t scanNum,
746 : uint32_t subscanNum,
747 : uint32_t numAntenna,
748 : CorrelationMode correlationMode,
749 : const OptionalSpectralResolutionType& spectralResolutionType,
750 : SDMDataObject::DataStruct& dataStruct) {
751 536 : checkState(T_CORRDATAHEADER, "corrDataHeader");
752 :
753 536 : ostringstream oss;
754 536 : oss << "/" << execBlockNum << "/" << scanNum << "/" << subscanNum;
755 536 : subscanPath_ = oss.str();
756 :
757 536 : sdmDataObject_.valid_ = true;
758 :
759 536 : sdmDataObject_.title_ = title_;
760 536 : sdmDataObject_.startTime_ = startTime;
761 536 : sdmDataObject_.dataOID_ = uid_;
762 536 : sdmDataObject_.dimensionality_ = 1;
763 536 : sdmDataObject_.numTime_ = 0;
764 536 : sdmDataObject_.execBlockUID_ = execBlockUID;
765 536 : sdmDataObject_.execBlockNum_ = execBlockNum;
766 536 : sdmDataObject_.scanNum_ = scanNum;
767 536 : sdmDataObject_.subscanNum_ = subscanNum;
768 536 : sdmDataObject_.numAntenna_ = numAntenna;
769 536 : sdmDataObject_.correlationMode_ = correlationMode;
770 536 : sdmDataObject_.spectralResolutionType_ = spectralResolutionType;
771 536 : sdmDataObject_.processorType_ = CORRELATOR;
772 536 : sdmDataObject_.dataStruct_ = dataStruct;
773 :
774 536 : outputln("--"+MIMEBOUNDARY_1);
775 536 : outputln("Content-Type: text/xml; charset=\"UTF-8\"");
776 536 : outputln("Content-Transfer-Encoding: 8bit");
777 536 : outputln("Content-Location: " + sdmDataObject_.projectPath() + "desc.xml");
778 536 : outputln();
779 :
780 536 : outputln(sdmDataObject_.toXML());
781 536 : }
782 :
783 :
784 4532 : void SDMDataObjectWriter::addData(uint32_t integrationNum,
785 : uint32_t subintegrationNum,
786 : uint64_t time,
787 : uint64_t interval,
788 : const vector<FLAGSTYPE>& flags,
789 : const vector<ACTUALTIMESTYPE>& actualTimes,
790 : const vector<ACTUALDURATIONSTYPE>& actualDurations,
791 : const vector<ZEROLAGSTYPE>& zeroLags,
792 : const vector<INTCROSSDATATYPE>& intCrossData,
793 : const vector<SHORTCROSSDATATYPE>& shortCrossData,
794 : const vector<FLOATCROSSDATATYPE>& floatCrossData,
795 : const vector<AUTODATATYPE>& autoData) {
796 4532 : SDMDataSubset sdmDataSubset(&sdmDataObject_);
797 4532 : sdmDataObject_.numTime_++;
798 4532 : sdmDataSubsetNum_++;
799 :
800 : // integrationNum and subintegrationNum.
801 4532 : sdmDataSubset.integrationNum_ = integrationNum;
802 4532 : sdmDataSubset.subintegrationNum_ = subintegrationNum?subintegrationNum:0;
803 :
804 : // The time.
805 4532 : sdmDataSubset.time_ = time;
806 :
807 : // The interval.
808 4532 : sdmDataSubset.interval_ = interval;
809 :
810 : // The crossDataType.
811 4532 : if (intCrossData.size() != 0)
812 0 : sdmDataSubset.crossDataType_ = INT32_TYPE;
813 :
814 4532 : else if (shortCrossData.size() != 0)
815 0 : sdmDataSubset.crossDataType_ = INT16_TYPE;
816 :
817 4532 : else if (floatCrossData.size() != 0)
818 4532 : sdmDataSubset.crossDataType_ = FLOAT32_TYPE;
819 :
820 : // Attachments size;
821 4532 : sdmDataSubset.nActualTimes_ = actualTimes.size();
822 4532 : sdmDataSubset.nActualDurations_ = actualDurations.size();
823 :
824 : // Ignore unconditionally zeroLags for FXF ~ ACA)
825 4532 : if (sdmDataObject_.correlatorType() != FX) {
826 4492 : sdmDataSubset.nZeroLags_ = zeroLags.size();
827 : }
828 : else
829 40 : sdmDataSubset.nZeroLags_ = 0;
830 :
831 4532 : sdmDataSubset.nFlags_ = flags.size();
832 4532 : sdmDataSubset.nFlags_ = flags.size();
833 4532 : switch (sdmDataSubset.crossDataType_) {
834 0 : case INT32_TYPE:
835 0 : sdmDataSubset.nCrossData_ = intCrossData.size();
836 0 : break;
837 0 : case INT16_TYPE:
838 0 : sdmDataSubset.nCrossData_ = shortCrossData.size();
839 0 : break;
840 4532 : case FLOAT32_TYPE:
841 4532 : sdmDataSubset.nCrossData_ = floatCrossData.size();
842 4532 : break;
843 0 : default:
844 0 : sdmDataSubset.nCrossData_ = 0;
845 : }
846 :
847 : //sdmDataSubset.nCrossData_ = shortCrossData.size() ? shortCrossData.size():intCrossData.size();
848 :
849 4532 : sdmDataSubset.nAutoData_ = autoData.size();
850 :
851 4532 : outputln("--"+MIMEBOUNDARY_1);
852 4532 : outputln("Content-Type: Multipart/Related; boundary=\""+MIMEBOUNDARY_2+"\";type=\"text/xml\"");
853 4532 : outputln("Content-Description: Data and metadata subset");
854 4532 : outputln("--"+MIMEBOUNDARY_2);
855 4532 : outputln("Content-Type: text/xml; charset=\"UTF-8\"");
856 4532 : outputln("Content-Location: " + sdmDataSubset.projectPath() + "desc.xml");
857 4532 : outputln();
858 4532 : outputln(sdmDataSubset.toXML());
859 :
860 :
861 4532 : if (flags.size() != 0) {
862 4532 : uint32_t numFlags = sdmDataObject_.dataStruct_.flags_.size();
863 4532 : if (numFlags !=0 && numFlags != flags.size()) {
864 0 : ostringstream oss;
865 0 : oss << "The number of values provided for 'flags' ("
866 0 : << flags.size()
867 0 : << "), is not equal to the number declared in the global header ("
868 0 : << numFlags << ").";
869 0 : throw SDMDataObjectWriterException(oss.str());
870 0 : }
871 4532 : outputln("--"+MIMEBOUNDARY_2);
872 4532 : outputln("Content-Type: binary/octet-stream");
873 4532 : outputlnLocation("flags", sdmDataSubset);
874 4532 : outputln();
875 4532 : outputln<uint32_t>(flags);
876 : }
877 :
878 :
879 4532 : if (actualTimes.size() != 0) {
880 0 : uint32_t numActualTimes = sdmDataObject_.dataStruct_.actualTimes_.size();
881 0 : if (numActualTimes != 0 && numActualTimes != actualTimes.size()) {
882 0 : ostringstream oss;
883 0 : oss << "The number of values provided for 'actualTimes' ("
884 0 : << actualTimes.size()
885 0 : << "), is not equal to the number declared in the global header ("
886 0 : << numActualTimes << ").";
887 0 : throw SDMDataObjectWriterException(oss.str());
888 0 : }
889 0 : outputln("--"+MIMEBOUNDARY_2);
890 0 : outputln("Content-Type: binary/octet-stream");
891 0 : outputlnLocation("actualTimes", sdmDataSubset);
892 0 : outputln();
893 0 : outputln<ACTUALTIMESTYPE>(actualTimes);
894 : }
895 :
896 4532 : if (actualDurations.size() != 0) {
897 0 : uint32_t numActualDurations = sdmDataObject_.dataStruct_.actualDurations_.size();
898 0 : if (numActualDurations != 0 && numActualDurations != actualDurations.size()) {
899 0 : ostringstream oss;
900 0 : oss << "The number of values provided for 'actualDurations' ("
901 0 : << actualDurations.size()
902 0 : << "), is not equal to the number declared in the global header ("
903 0 : << numActualDurations << ").";
904 0 : throw SDMDataObjectWriterException(oss.str());
905 0 : }
906 0 : outputln("--"+MIMEBOUNDARY_2);
907 0 : outputln("Content-Type: binary/octet-stream");
908 0 : outputlnLocation("actualDurations", sdmDataSubset);
909 0 : outputln();
910 0 : outputln<ACTUALDURATIONSTYPE>(actualDurations);
911 : }
912 :
913 :
914 4532 : if (sdmDataObject_.correlationMode_ != AUTO_ONLY) {
915 4532 : int numCrossData = sdmDataObject_.dataStruct_.crossData_.size();
916 4532 : int numCrossDataV = 0; //= intCrossData.size() ? intCrossData.size():shortCrossData.size();
917 4532 : switch(sdmDataSubset.crossDataType_) {
918 0 : case INT32_TYPE:
919 0 : numCrossDataV = intCrossData.size();
920 0 : break;
921 0 : case INT16_TYPE:
922 0 : numCrossDataV = shortCrossData.size();
923 0 : break;
924 4532 : case FLOAT32_TYPE:
925 4532 : numCrossDataV = floatCrossData.size();
926 4532 : break;
927 0 : default:
928 0 : break;
929 : }
930 4532 : if (numCrossData != numCrossDataV) {
931 0 : ostringstream oss;
932 0 : oss << "The number of values provided for 'crossData' ("
933 : << numCrossDataV
934 0 : << "), is not equal to the number declared in the global header ("
935 0 : << numCrossData << ").";
936 0 : throw SDMDataObjectWriterException(oss.str());
937 0 : }
938 4532 : outputln("--"+MIMEBOUNDARY_2);
939 4532 : outputln("Content-Type: binary/octet-stream");
940 4532 : outputlnLocation("crossData", sdmDataSubset);
941 4532 : outputln();
942 4532 : switch (sdmDataSubset.crossDataType_) {
943 0 : case INT32_TYPE:
944 0 : outputln<int>(intCrossData);
945 0 : break;
946 0 : case INT16_TYPE:
947 0 : outputln<short>(shortCrossData);
948 0 : break;
949 4532 : case FLOAT32_TYPE:
950 4532 : outputln<float>(floatCrossData);
951 4532 : break;
952 0 : default:
953 0 : throw SDMDataObjectWriterException("'" + CPrimitiveDataType::name(sdmDataSubset.crossDataType_)+"' data are not processed here.");
954 : }
955 : }
956 :
957 4532 : if (sdmDataObject_.correlationMode_ != CROSS_ONLY) {
958 3024 : uint32_t numAutoData = sdmDataObject_.dataStruct_.autoData_.size();
959 3024 : if (numAutoData != autoData.size()) {
960 0 : ostringstream oss;
961 0 : oss << "The number of values provided for 'autoData' ("
962 0 : << autoData.size()
963 0 : << "), is not equal to the number declared in the global header ("
964 0 : << numAutoData << ").";
965 0 : throw SDMDataObjectWriterException(oss.str());
966 0 : }
967 3024 : outputln("--"+MIMEBOUNDARY_2);
968 3024 : outputln("Content-Type: binary/octet-stream");
969 3024 : outputlnLocation("autoData", sdmDataSubset);
970 3024 : outputln();
971 3024 : outputln<float>(autoData);
972 : }
973 :
974 : // if (sdmDataObject_.spectralResolutionType_ != CHANNEL_AVERAGE) {
975 : // Now the zeroLags are optionally allowed in CHANNEL_AVERAGE
976 : // zeroLags are now optional in any case - Michel Caillat - 24 Jul 2008
977 4532 : uint32_t numZeroLags = sdmDataObject_.dataStruct_.zeroLags_.size();
978 4532 : if (numZeroLags > 0) {
979 0 : if (numZeroLags != zeroLags.size()) {
980 0 : ostringstream oss;
981 0 : oss << "The number of values provided for 'zeroLags' ("
982 0 : << zeroLags.size()
983 0 : << "), is not equal to the number declared in the global header ("
984 0 : << numZeroLags << ").";
985 0 : throw SDMDataObjectWriterException(oss.str());
986 0 : }
987 0 : outputln("--"+MIMEBOUNDARY_2);
988 0 : outputln("Content-Type: binary/octet-stream");
989 0 : outputlnLocation("zeroLags", sdmDataSubset);
990 0 : outputln();
991 0 : outputln<float>(zeroLags);
992 : }
993 :
994 4532 : outputln("--"+MIMEBOUNDARY_2+"--");
995 4532 : }
996 :
997 0 : void SDMDataObjectWriter::addIntegration(uint32_t integrationNum,
998 : uint64_t time,
999 : uint64_t interval,
1000 : const vector<FLAGSTYPE>& flags,
1001 : const vector<ACTUALTIMESTYPE>& actualTimes,
1002 : const vector<ACTUALDURATIONSTYPE>& actualDurations,
1003 : const vector<ZEROLAGSTYPE>& zeroLags,
1004 : const vector<INTCROSSDATATYPE>& crossData,
1005 : const vector<AUTODATATYPE>& autoData) {
1006 :
1007 0 : checkState(T_ADDINTEGRATION, "addIntegration");
1008 :
1009 0 : vector<short> emptyShort;
1010 0 : vector<float> emptyFloat;
1011 0 : addData(integrationNum,
1012 : 0,
1013 : time,
1014 : interval,
1015 : flags,
1016 : actualTimes,
1017 : actualDurations,
1018 : zeroLags,
1019 : crossData,
1020 : emptyShort,
1021 : emptyFloat,
1022 : autoData);
1023 0 : }
1024 :
1025 :
1026 0 : void SDMDataObjectWriter::addIntegration(uint32_t integrationNum,
1027 : uint64_t time,
1028 : uint64_t interval,
1029 : const vector<FLAGSTYPE>& flags,
1030 : const vector<ACTUALTIMESTYPE>& actualTimes,
1031 : const vector<ACTUALDURATIONSTYPE>& actualDurations,
1032 : const vector<ZEROLAGSTYPE>& zeroLags,
1033 : const vector<SHORTCROSSDATATYPE>& crossData,
1034 : const vector<AUTODATATYPE>& autoData) {
1035 0 : checkState(T_ADDINTEGRATION, "addIntegration");
1036 :
1037 0 : vector<int> emptyLong;
1038 0 : vector<float> emptyFloat;
1039 0 : addData(integrationNum,
1040 : 0,
1041 : time,
1042 : interval,
1043 : flags,
1044 : actualTimes,
1045 : actualDurations,
1046 : zeroLags,
1047 : emptyLong,
1048 : crossData,
1049 : emptyFloat,
1050 : autoData);
1051 0 : }
1052 :
1053 4532 : void SDMDataObjectWriter::addIntegration(uint32_t integrationNum,
1054 : uint64_t time,
1055 : uint64_t interval,
1056 : const vector<FLAGSTYPE>& flags,
1057 : const vector<ACTUALTIMESTYPE>& actualTimes,
1058 : const vector<ACTUALDURATIONSTYPE>& actualDurations,
1059 : const vector<ZEROLAGSTYPE>& zeroLags,
1060 : const vector<FLOATCROSSDATATYPE>& crossData,
1061 : const vector<AUTODATATYPE>& autoData) {
1062 4532 : checkState(T_ADDINTEGRATION, "addIntegration");
1063 :
1064 4532 : vector<int> emptyLong;
1065 4532 : vector<short> emptyShort;
1066 4532 : addData(integrationNum,
1067 : 0,
1068 : time,
1069 : interval,
1070 : flags,
1071 : actualTimes,
1072 : actualDurations,
1073 : zeroLags,
1074 : emptyLong,
1075 : emptyShort,
1076 : crossData,
1077 : autoData);
1078 4532 : }
1079 :
1080 0 : void SDMDataObjectWriter::addSubintegration(uint32_t integrationNum,
1081 : uint32_t subIntegrationNum,
1082 : uint64_t time,
1083 : uint64_t interval,
1084 : const vector<FLAGSTYPE>& flags,
1085 : const vector<ACTUALTIMESTYPE>& actualTimes,
1086 : const vector<ACTUALDURATIONSTYPE>& actualDurations,
1087 : const vector<ZEROLAGSTYPE>& zeroLags,
1088 : const vector<SHORTCROSSDATATYPE>& crossData,
1089 : const vector<AUTODATATYPE>& autoData) {
1090 0 : checkState(T_ADDSUBINTEGRATION, "addSubintegration");
1091 :
1092 0 : vector<int> emptyLong;
1093 0 : vector<float> emptyFloat;
1094 0 : addData(integrationNum,
1095 : subIntegrationNum,
1096 : time,
1097 : interval,
1098 : flags,
1099 : actualTimes,
1100 : actualDurations,
1101 : zeroLags,
1102 : emptyLong,
1103 : crossData,
1104 : emptyFloat,
1105 : autoData);
1106 0 : }
1107 :
1108 0 : void SDMDataObjectWriter::addSubintegration(uint32_t integrationNum,
1109 : uint32_t subIntegrationNum,
1110 : uint64_t time,
1111 : uint64_t interval,
1112 : const vector<FLAGSTYPE>& flags,
1113 : const vector<ACTUALTIMESTYPE>& actualTimes,
1114 : const vector<ACTUALDURATIONSTYPE>& actualDurations,
1115 : const vector<ZEROLAGSTYPE>& zeroLags,
1116 : const vector<INTCROSSDATATYPE>& crossData,
1117 : const vector<AUTODATATYPE>& autoData) {
1118 0 : checkState(T_ADDSUBINTEGRATION, "addSubIntegration");
1119 :
1120 0 : vector<short> emptyShort;
1121 0 : vector<float> emptyFloat;
1122 0 : addData(integrationNum,
1123 : subIntegrationNum,
1124 : time,
1125 : interval,
1126 : flags,
1127 : actualTimes,
1128 : actualDurations,
1129 : zeroLags,
1130 : crossData,
1131 : emptyShort,
1132 : emptyFloat,
1133 : autoData);
1134 0 : }
1135 :
1136 0 : void SDMDataObjectWriter::addSubintegration(uint32_t integrationNum,
1137 : uint32_t subIntegrationNum,
1138 : uint64_t time,
1139 : uint64_t interval,
1140 : const vector<FLAGSTYPE>& flags,
1141 : const vector<ACTUALTIMESTYPE>& actualTimes,
1142 : const vector<ACTUALDURATIONSTYPE>& actualDurations,
1143 : const vector<ZEROLAGSTYPE>& zeroLags,
1144 : const vector<FLOATCROSSDATATYPE>& crossData,
1145 : const vector<AUTODATATYPE>& autoData) {
1146 0 : checkState(T_ADDSUBINTEGRATION, "addSubIntegration");
1147 :
1148 0 : vector<int> emptyLong;
1149 0 : vector<short> emptyShort;
1150 0 : addData(integrationNum,
1151 : subIntegrationNum,
1152 : time,
1153 : interval,
1154 : flags,
1155 : actualTimes,
1156 : actualDurations,
1157 : zeroLags,
1158 : emptyLong,
1159 : emptyShort,
1160 : crossData,
1161 : autoData);
1162 0 : }
1163 :
1164 0 : uint64_t SDMDataObjectWriter::numBytes() { return numBytes_; }
1165 :
1166 :
1167 3 : bool SDMDataObjectWriter::initClass() {
1168 : //
1169 : // WVR data are stored in the following order : TIM, ANT, SPP (SPP varying faster then ANT varying itself faster than TIM)
1170 : //
1171 3 : WVRDATAAXES.push_back(TIM);
1172 3 : WVRDATAAXES.push_back(ANT);
1173 3 : WVRDATAAXES.push_back(SPP);
1174 :
1175 : //
1176 : // WVR data flags are stored in the following order : TIM, ANT (ANT varying itself faster than TIM)
1177 : //
1178 3 : WVRDATAFLAGSAXES.push_back(TIM);
1179 3 : WVRDATAFLAGSAXES.push_back(ANT);
1180 :
1181 3 : return true;
1182 : }
1183 :
1184 5604 : void SDMDataObjectWriter:: checkState(Transitions t, const string& methodName) {
1185 5604 : switch(currentState_) {
1186 536 : case START:
1187 536 : if (t == T_TPDATA ) {
1188 0 : currentState_ = S_TPDATA;
1189 0 : return;
1190 : }
1191 536 : else if (t == T_TPDATAHEADER ) {
1192 0 : currentState_ = S_TPDATAHEADER;
1193 0 : return;
1194 : }
1195 536 : else if (t == T_CORRDATAHEADER) {
1196 536 : currentState_ = S_CORRDATAHEADER;
1197 536 : return;
1198 : }
1199 0 : else if (t == T_WVRDATA) {
1200 0 : currentState_ = S_WVRDATA;
1201 0 : return;
1202 : }
1203 0 : break;
1204 :
1205 0 : case S_TPDATA:
1206 0 : if (t == T_DONE) {
1207 0 : currentState_ = END;
1208 0 : return;
1209 : }
1210 0 : break;
1211 :
1212 :
1213 0 : case S_TPDATAHEADER:
1214 0 : if (t == T_ADDTPSUBSCAN) {
1215 0 : currentState_ = S_ADDTPSUBSCAN;
1216 0 : return;
1217 : }
1218 0 : else if (t == T_ADDTPINTEGRATION) {
1219 0 : currentState_ = S_ADDTPINTEGRATION;
1220 0 : return;
1221 : }
1222 0 : break;
1223 :
1224 0 : case S_ADDTPINTEGRATION:
1225 0 : if (t == T_ADDTPINTEGRATION) {
1226 0 : return;
1227 : }
1228 0 : else if ( t == T_DONE ) {
1229 0 : currentState_ = END;
1230 0 : return;
1231 : }
1232 0 : break;
1233 :
1234 0 : case S_ADDTPSUBSCAN:
1235 0 : if ( t == T_DONE ) {
1236 0 : currentState_ = END;
1237 0 : return;
1238 : }
1239 0 : break;
1240 :
1241 0 : case S_WVRDATA:
1242 0 : if (t == T_DONE) {
1243 0 : currentState_ = END;
1244 0 : return;
1245 : }
1246 0 : break;
1247 :
1248 536 : case S_CORRDATAHEADER:
1249 536 : if (t == T_ADDINTEGRATION) {
1250 536 : currentState_ = S_ADDINTEGRATION;
1251 536 : return;
1252 : }
1253 0 : else if (t == T_ADDSUBINTEGRATION) {
1254 0 : currentState_ = S_ADDSUBINTEGRATION;
1255 0 : return;
1256 : }
1257 0 : break;
1258 :
1259 4532 : case S_ADDINTEGRATION:
1260 4532 : if (t == T_ADDINTEGRATION)
1261 3996 : return;
1262 536 : else if (t == T_DONE) {
1263 536 : currentState_ = END;
1264 536 : return;
1265 : }
1266 0 : break;
1267 :
1268 :
1269 0 : case S_ADDSUBINTEGRATION:
1270 0 : if (t == T_ADDSUBINTEGRATION)
1271 0 : return;
1272 0 : else if (t == T_DONE) {
1273 0 : currentState_ = END;
1274 0 : return;
1275 : }
1276 0 : break;
1277 :
1278 :
1279 0 : case END:
1280 0 : break;
1281 : }
1282 0 : throw SDMDataObjectWriterException("Invalid call of method '" + methodName + "'");
1283 : }
1284 : }
1285 :
1286 :
|