Line data Source code
1 :
2 : /*
3 : * ALMA - Atacama Large Millimeter Array
4 : * (c) European Southern Observatory, 2002
5 : * (c) Associated Universities Inc., 2002
6 : * Copyright by ESO (in the framework of the ALMA collaboration),
7 : * Copyright by AUI (in the framework of the ALMA collaboration),
8 : * All rights reserved.
9 : *
10 : * This library is free software; you can redistribute it and/or
11 : * modify it under the terms of the GNU Lesser General Public
12 : * License as published by the Free software Foundation; either
13 : * version 2.1 of the License, or (at your option) any later version.
14 : *
15 : * This library is distributed in the hope that it will be useful,
16 : * but WITHOUT ANY WARRANTY, without even the implied warranty of
17 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 : * Lesser General Public License for more details.
19 : *
20 : * You should have received a copy of the GNU Lesser General Public
21 : * License along with this library; if not, write to the Free Software
22 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 : * MA 02111-1307 USA
24 : *
25 : * Warning!
26 : * --------------------------------------------------------------------
27 : * | This is generated code! Do not modify this file. |
28 : * | If you do, all changes will be lost when the file is re-generated. |
29 : * --------------------------------------------------------------------
30 : *
31 : * File CalDelayTable.h
32 : */
33 :
34 : #ifndef CalDelayTable_CLASS
35 : #define CalDelayTable_CLASS
36 :
37 : #include <string>
38 : #include <vector>
39 : #include <map>
40 :
41 :
42 :
43 :
44 : #include <alma/ASDM/Angle.h>
45 :
46 :
47 :
48 : #include <alma/ASDM/ArrayTime.h>
49 :
50 :
51 :
52 : #include <alma/ASDM/Frequency.h>
53 :
54 :
55 :
56 : #include <alma/ASDM/Tag.h>
57 :
58 :
59 :
60 :
61 :
62 :
63 :
64 :
65 : #include <alma/Enumerations/CAtmPhaseCorrection.h>
66 :
67 :
68 :
69 : #include <alma/Enumerations/CBasebandName.h>
70 :
71 :
72 :
73 : #include <alma/Enumerations/CReceiverBand.h>
74 :
75 :
76 :
77 :
78 :
79 :
80 :
81 :
82 :
83 :
84 :
85 :
86 :
87 :
88 :
89 : #include <alma/Enumerations/CPolarizationType.h>
90 :
91 :
92 :
93 :
94 :
95 :
96 :
97 :
98 :
99 :
100 :
101 :
102 :
103 :
104 :
105 :
106 :
107 : #include <alma/Enumerations/CReceiverSideband.h>
108 :
109 :
110 :
111 :
112 : #include <alma/ASDM/ConversionException.h>
113 : #include <alma/ASDM/DuplicateKey.h>
114 : #include <alma/ASDM/UniquenessViolationException.h>
115 : #include <alma/ASDM/NoSuchRow.h>
116 : #include <alma/ASDM/DuplicateKey.h>
117 :
118 :
119 : #ifndef WITHOUT_ACS
120 : #include <asdmIDLC.h>
121 : #endif
122 :
123 : #include <alma/ASDM/Representable.h>
124 :
125 : #include <pthread.h>
126 :
127 : namespace asdm {
128 :
129 : //class asdm::ASDM;
130 : //class asdm::CalDelayRow;
131 :
132 : class ASDM;
133 : class CalDelayRow;
134 : /**
135 : * The CalDelayTable class is an Alma table.
136 : * <BR>
137 : *
138 : * \par Role
139 : * Result of delay offset calibration performed on-line by TelCal. This calibration determines the delay offsets to be added in the correlator to compensate for residual cable delays. Delays are entered in seconds but represented as double precision floating point numbers.
140 : * <BR>
141 :
142 : * Generated from model's revision "-1", branch ""
143 : *
144 : * <TABLE BORDER="1">
145 : * <CAPTION> Attributes of CalDelay </CAPTION>
146 : * <TR BGCOLOR="#AAAAAA"> <TH> Name </TH> <TH> Type </TH> <TH> Expected shape </TH> <TH> Comment </TH></TR>
147 :
148 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" align="center"> Key </TD></TR>
149 :
150 : * <TR>
151 :
152 : * <TD> antennaName </TD>
153 :
154 : * <TD> std::string</TD>
155 : * <TD> </TD>
156 : * <TD> the name of the antenna. </TD>
157 : * </TR>
158 :
159 : * <TR>
160 :
161 : * <TD> atmPhaseCorrection </TD>
162 :
163 : * <TD> AtmPhaseCorrectionMod::AtmPhaseCorrection</TD>
164 : * <TD> </TD>
165 : * <TD> qualifies how the atmospheric phase correction has been applied. </TD>
166 : * </TR>
167 :
168 : * <TR>
169 :
170 : * <TD> basebandName </TD>
171 :
172 : * <TD> BasebandNameMod::BasebandName</TD>
173 : * <TD> </TD>
174 : * <TD> Name of the Baseband </TD>
175 : * </TR>
176 :
177 : * <TR>
178 :
179 : * <TD> receiverBand </TD>
180 :
181 : * <TD> ReceiverBandMod::ReceiverBand</TD>
182 : * <TD> </TD>
183 : * <TD> identifies the receiver band. </TD>
184 : * </TR>
185 :
186 : * <TR>
187 :
188 : * <TD> calDataId </TD>
189 :
190 : * <TD> Tag</TD>
191 : * <TD> </TD>
192 : * <TD> refers to a unique row in CalData Table. </TD>
193 : * </TR>
194 :
195 : * <TR>
196 :
197 : * <TD> calReductionId </TD>
198 :
199 : * <TD> Tag</TD>
200 : * <TD> </TD>
201 : * <TD> refers to a unique row in CalReduction Table. </TD>
202 : * </TR>
203 :
204 :
205 :
206 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Mandatory) </TH></TR>
207 :
208 : * <TR>
209 : * <TD> startValidTime </TD>
210 : * <TD> ArrayTime </TD>
211 : * <TD> </TD>
212 : * <TD> the start time of the result validity period. </TD>
213 : * </TR>
214 :
215 : * <TR>
216 : * <TD> endValidTime </TD>
217 : * <TD> ArrayTime </TD>
218 : * <TD> </TD>
219 : * <TD> the end time of the result validity period. </TD>
220 : * </TR>
221 :
222 : * <TR>
223 : * <TD> refAntennaName </TD>
224 : * <TD> std::string </TD>
225 : * <TD> </TD>
226 : * <TD> the name of the reference antenna. </TD>
227 : * </TR>
228 :
229 : * <TR>
230 : * <TD> numReceptor (numReceptor)</TD>
231 : * <TD> int </TD>
232 : * <TD> </TD>
233 : * <TD> the number of receptors. </TD>
234 : * </TR>
235 :
236 : * <TR>
237 : * <TD> delayError </TD>
238 : * <TD> std::vector<double > </TD>
239 : * <TD> numReceptor </TD>
240 : * <TD> the uncertainties on the measured delay offsets (one value per receptor). </TD>
241 : * </TR>
242 :
243 : * <TR>
244 : * <TD> delayOffset </TD>
245 : * <TD> std::vector<double > </TD>
246 : * <TD> numReceptor </TD>
247 : * <TD> the measured delay offsets (one value per receptor). </TD>
248 : * </TR>
249 :
250 : * <TR>
251 : * <TD> polarizationTypes </TD>
252 : * <TD> std::vector<PolarizationTypeMod::PolarizationType > </TD>
253 : * <TD> numReceptor </TD>
254 : * <TD> identifies the polarizations of the receptors (one value per receptor). </TD>
255 : * </TR>
256 :
257 : * <TR>
258 : * <TD> reducedChiSquared </TD>
259 : * <TD> std::vector<double > </TD>
260 : * <TD> numReceptor </TD>
261 : * <TD> measure of the quality of the fit (one value per receptor). </TD>
262 : * </TR>
263 :
264 : * <TR>
265 : * <TD> appliedDelay </TD>
266 : * <TD> std::vector<double > </TD>
267 : * <TD> numReceptor </TD>
268 : * <TD> the delay that was applied (one value per receptor). </TD>
269 : * </TR>
270 :
271 :
272 :
273 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Optional) </TH></TR>
274 :
275 : * <TR>
276 : * <TD> crossDelayOffset</TD>
277 : * <TD> double </TD>
278 : * <TD> </TD>
279 : * <TD> the measured cross delay offset (reference antenna only). </TD>
280 : * </TR>
281 :
282 : * <TR>
283 : * <TD> crossDelayOffsetError</TD>
284 : * <TD> double </TD>
285 : * <TD> </TD>
286 : * <TD> the uncertainty for the cross delay offset. </TD>
287 : * </TR>
288 :
289 : * <TR>
290 : * <TD> numSideband(numSideband)</TD>
291 : * <TD> int </TD>
292 : * <TD> </TD>
293 : * <TD> the number of sideband. </TD>
294 : * </TR>
295 :
296 : * <TR>
297 : * <TD> refFreq</TD>
298 : * <TD> std::vector<Frequency > </TD>
299 : * <TD> numSideband </TD>
300 : * <TD> the reference frequencies (one value per sideband). </TD>
301 : * </TR>
302 :
303 : * <TR>
304 : * <TD> refFreqPhase</TD>
305 : * <TD> std::vector<Angle > </TD>
306 : * <TD> numSideband </TD>
307 : * <TD> the phases at reference frequencies (one value per sideband). </TD>
308 : * </TR>
309 :
310 : * <TR>
311 : * <TD> sidebands</TD>
312 : * <TD> std::vector<ReceiverSidebandMod::ReceiverSideband > </TD>
313 : * <TD> numSideband </TD>
314 : * <TD> identifies the receiver's sidebands (one value per sideband). </TD>
315 : * </TR>
316 :
317 :
318 : * </TABLE>
319 : */
320 : class CalDelayTable : public Representable {
321 : friend class ASDM;
322 :
323 : public:
324 :
325 :
326 : /**
327 : * Return the list of field names that make up key key
328 : * as an array of strings.
329 : * @return a vector of string.
330 : */
331 : static const std::vector<std::string>& getKeyName();
332 :
333 :
334 : virtual ~CalDelayTable();
335 :
336 : /**
337 : * Return the container to which this table belongs.
338 : *
339 : * @return the ASDM containing this table.
340 : */
341 : ASDM &getContainer() const;
342 :
343 : /**
344 : * Return the number of rows in the table.
345 : *
346 : * @return the number of rows in an unsigned int.
347 : */
348 : unsigned int size() const;
349 :
350 : /**
351 : * Return the name of this table.
352 : *
353 : * This is a instance method of the class.
354 : *
355 : * @return the name of this table in a string.
356 : */
357 : std::string getName() const;
358 :
359 : /**
360 : * Return the name of this table.
361 : *
362 : * This is a static method of the class.
363 : *
364 : * @return the name of this table in a string.
365 : */
366 : static std::string name() ;
367 :
368 : /**
369 : * Return the version information about this table.
370 : *
371 : */
372 : std::string getVersion() const ;
373 :
374 : /**
375 : * Return the names of the attributes of this table.
376 : *
377 : * @return a vector of string
378 : */
379 : static const std::vector<std::string>& getAttributesNames();
380 :
381 : /**
382 : * Return the default sorted list of attributes names in the binary representation of the table.
383 : *
384 : * @return a const reference to a vector of string
385 : */
386 : static const std::vector<std::string>& defaultAttributesNamesInBin();
387 :
388 : /**
389 : * Return this table's Entity.
390 : */
391 : Entity getEntity() const;
392 :
393 : /**
394 : * Set this table's Entity.
395 : * @param e An entity.
396 : */
397 : void setEntity(Entity e);
398 :
399 : /**
400 : * Produces an XML representation conform
401 : * to the schema defined for CalDelay (CalDelayTable.xsd).
402 : *
403 : * @returns a string containing the XML representation.
404 : * @throws ConversionException
405 : */
406 : std::string toXML() ;
407 :
408 : #ifndef WITHOUT_ACS
409 : // Conversion Methods
410 : /**
411 : * Convert this table into a CalDelayTableIDL CORBA structure.
412 : *
413 : * @return a pointer to a CalDelayTableIDL
414 : */
415 : asdmIDL::CalDelayTableIDL *toIDL() ;
416 :
417 : /**
418 : * Fills the CORBA data structure passed in parameter
419 : * with the content of this table.
420 : *
421 : * @param x a reference to the asdmIDL::CalDelayTableIDL to be populated
422 : * with the content of this.
423 : */
424 : void toIDL(asdmIDL::CalDelayTableIDL& x) const;
425 :
426 : #endif
427 :
428 : #ifndef WITHOUT_ACS
429 : /**
430 : * Populate this table from the content of a CalDelayTableIDL Corba structure.
431 : *
432 : * @throws DuplicateKey Thrown if the method tries to add a row having a key that is already in the table.
433 : * @throws ConversionException
434 : */
435 : void fromIDL(asdmIDL::CalDelayTableIDL x) ;
436 : #endif
437 :
438 : //
439 : // ====> Row creation.
440 : //
441 :
442 : /**
443 : * Create a new row with default values.
444 : * @return a pointer on a CalDelayRow
445 : */
446 : CalDelayRow *newRow();
447 :
448 :
449 : /**
450 : * Create a new row initialized to the specified values.
451 : * @return a pointer on the created and initialized row.
452 :
453 : * @param antennaName
454 :
455 : * @param atmPhaseCorrection
456 :
457 : * @param basebandName
458 :
459 : * @param receiverBand
460 :
461 : * @param calDataId
462 :
463 : * @param calReductionId
464 :
465 : * @param startValidTime
466 :
467 : * @param endValidTime
468 :
469 : * @param refAntennaName
470 :
471 : * @param numReceptor
472 :
473 : * @param delayError
474 :
475 : * @param delayOffset
476 :
477 : * @param polarizationTypes
478 :
479 : * @param reducedChiSquared
480 :
481 : * @param appliedDelay
482 :
483 : */
484 : CalDelayRow *newRow(std::string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, BasebandNameMod::BasebandName basebandName, ReceiverBandMod::ReceiverBand receiverBand, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, std::string refAntennaName, int numReceptor, std::vector<double > delayError, std::vector<double > delayOffset, std::vector<PolarizationTypeMod::PolarizationType > polarizationTypes, std::vector<double > reducedChiSquared, std::vector<double > appliedDelay);
485 :
486 :
487 :
488 : /**
489 : * Create a new row using a copy constructor mechanism.
490 : *
491 : * The method creates a new CalDelayRow owned by this. Each attribute of the created row
492 : * is a (deep) copy of the corresponding attribute of row. The method does not add
493 : * the created row to this, its simply parents it to this, a call to the add method
494 : * has to be done in order to get the row added (very likely after having modified
495 : * some of its attributes).
496 : * If row is null then the method returns a new CalDelayRow with default values for its attributes.
497 : *
498 : * @param row the row which is to be copied.
499 : */
500 : CalDelayRow *newRow(CalDelayRow *row);
501 :
502 : //
503 : // ====> Append a row to its table.
504 : //
505 :
506 :
507 : /**
508 : * Add a row.
509 : * @param x a pointer to the CalDelayRow to be added.
510 : *
511 : * @return a pointer to a CalDelayRow. If the table contains a CalDelayRow whose attributes (key and mandatory values) are equal to x ones
512 : * then returns a pointer on that CalDelayRow, otherwise returns x.
513 : *
514 : * @throw DuplicateKey { thrown when the table contains a CalDelayRow with a key equal to the x one but having
515 : * and a value section different from x one }
516 : *
517 :
518 : */
519 : CalDelayRow* add(CalDelayRow* x) ;
520 :
521 :
522 :
523 :
524 :
525 : //
526 : // ====> Methods returning rows.
527 : //
528 :
529 : /**
530 : * Get a collection of pointers on the rows of the table.
531 : * @return Alls rows in a vector of pointers of CalDelayRow. The elements of this vector are stored in the order
532 : * in which they have been added to the CalDelayTable.
533 : */
534 : std::vector<CalDelayRow *> get() ;
535 :
536 : /**
537 : * Get a const reference on the collection of rows pointers internally hold by the table.
538 : * @return A const reference of a vector of pointers of CalDelayRow. The elements of this vector are stored in the order
539 : * in which they have been added to the CalDelayTable.
540 : *
541 : */
542 : const std::vector<CalDelayRow *>& get() const ;
543 :
544 :
545 :
546 :
547 :
548 : /**
549 : * Returns a CalDelayRow* given a key.
550 : * @return a pointer to the row having the key whose values are passed as parameters, or 0 if
551 : * no row exists for that key.
552 :
553 : * @param antennaName
554 :
555 : * @param atmPhaseCorrection
556 :
557 : * @param basebandName
558 :
559 : * @param receiverBand
560 :
561 : * @param calDataId
562 :
563 : * @param calReductionId
564 :
565 : *
566 : */
567 : CalDelayRow* getRowByKey(std::string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, BasebandNameMod::BasebandName basebandName, ReceiverBandMod::ReceiverBand receiverBand, Tag calDataId, Tag calReductionId);
568 :
569 :
570 :
571 :
572 :
573 : /**
574 : * Look up the table for a row whose all attributes
575 : * are equal to the corresponding parameters of the method.
576 : * @return a pointer on this row if any, null otherwise.
577 : *
578 :
579 : * @param antennaName
580 :
581 : * @param atmPhaseCorrection
582 :
583 : * @param basebandName
584 :
585 : * @param receiverBand
586 :
587 : * @param calDataId
588 :
589 : * @param calReductionId
590 :
591 : * @param startValidTime
592 :
593 : * @param endValidTime
594 :
595 : * @param refAntennaName
596 :
597 : * @param numReceptor
598 :
599 : * @param delayError
600 :
601 : * @param delayOffset
602 :
603 : * @param polarizationTypes
604 :
605 : * @param reducedChiSquared
606 :
607 : * @param appliedDelay
608 :
609 : */
610 : CalDelayRow* lookup(std::string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, BasebandNameMod::BasebandName basebandName, ReceiverBandMod::ReceiverBand receiverBand, Tag calDataId, Tag calReductionId, ArrayTime startValidTime, ArrayTime endValidTime, std::string refAntennaName, int numReceptor, std::vector<double > delayError, std::vector<double > delayOffset, std::vector<PolarizationTypeMod::PolarizationType > polarizationTypes, std::vector<double > reducedChiSquared, std::vector<double > appliedDelay);
611 :
612 :
613 : void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
614 : BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
615 :
616 : private:
617 :
618 : /**
619 : * Create a CalDelayTable.
620 : * <p>
621 : * This constructor is private because only the
622 : * container can create tables. All tables must know the container
623 : * to which they belong.
624 : * @param container The container to which this table belongs.
625 : */
626 : CalDelayTable (ASDM & container);
627 :
628 : ASDM & container;
629 :
630 : bool archiveAsBin; // If true archive binary else archive XML
631 : bool fileAsBin ; // If true file binary else file XML
632 :
633 : std::string version ;
634 :
635 : Entity entity;
636 :
637 :
638 :
639 :
640 :
641 :
642 : /**
643 : * If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and throw exception if not.
644 : * Check if *x verifies the key uniqueness rule and throw an exception if not.
645 : * Append x to its table.
646 : * @throws DuplicateKey
647 :
648 : */
649 : CalDelayRow* checkAndAdd(CalDelayRow* x, bool skipCheckUniqueness=false) ;
650 :
651 : /**
652 : * Brutally append an CalDelayRow x to the collection of rows already stored in this table. No uniqueness check is done !
653 : *
654 : * @param CalDelayRow* x a pointer onto the CalDelayRow to be appended.
655 : */
656 : void append(CalDelayRow* x) ;
657 :
658 : /**
659 : * Brutally append an CalDelayRow x to the collection of rows already stored in this table. No uniqueness check is done !
660 : *
661 : * @param CalDelayRow* x a pointer onto the CalDelayRow to be appended.
662 : */
663 : void addWithoutCheckingUnique(CalDelayRow* x) ;
664 :
665 :
666 :
667 :
668 :
669 : // A data structure to store the pointers on the table's rows.
670 :
671 : // In all cases we maintain a private vector of CalDelayRow s.
672 : std::vector<CalDelayRow * > privateRows;
673 :
674 :
675 :
676 : std::vector<CalDelayRow *> row;
677 :
678 :
679 : void error() ; //throw(ConversionException);
680 :
681 :
682 : /**
683 : * Populate this table from the content of a XML document that is required to
684 : * be conform to the XML schema defined for a CalDelay (CalDelayTable.xsd).
685 : * @throws ConversionException
686 : *
687 : */
688 : void fromXML(std::string& xmlDoc) ;
689 :
690 : std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
691 :
692 : /**
693 : * Private methods involved during the build of this table out of the content
694 : * of file(s) containing an external representation of a CalDelay table.
695 : */
696 : void setFromMIMEFile(const std::string& directory);
697 : /*
698 : void openMIMEFile(const std::string& directory);
699 : */
700 : void setFromXMLFile(const std::string& directory);
701 :
702 : /**
703 : * Serialize this into a stream of bytes and encapsulates that stream into a MIME message.
704 : * @returns a string containing the MIME message.
705 : *
706 : * @param byteOrder a const pointer to a static instance of the class ByteOrder.
707 : *
708 : */
709 : std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
710 :
711 :
712 : /**
713 : * Extracts the binary part of a MIME message and deserialize its content
714 : * to fill this with the result of the deserialization.
715 : * @param mimeMsg the string containing the MIME message.
716 : * @throws ConversionException
717 : */
718 : void setFromMIME(const std::string & mimeMsg);
719 :
720 : /**
721 : * Private methods involved during the export of this table into disk file(s).
722 : */
723 : std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
724 :
725 : /**
726 : * Stores a representation (binary or XML) of this table into a file.
727 : *
728 : * Depending on the boolean value of its private field fileAsBin a binary serialization of this (fileAsBin==true)
729 : * will be saved in a file "CalDelay.bin" or an XML representation (fileAsBin==false) will be saved in a file "CalDelay.xml".
730 : * The file is always written in a directory whose name is passed as a parameter.
731 : * @param directory The name of directory where the file containing the table's representation will be saved.
732 : *
733 : */
734 : void toFile(std::string directory);
735 :
736 : /**
737 : * Load the table in memory if necessary.
738 : */
739 : bool loadInProgress;
740 0 : void checkPresenceInMemory() {
741 0 : if (!presentInMemory && !loadInProgress) {
742 0 : loadInProgress = true;
743 0 : setFromFile(getContainer().getDirectory());
744 0 : presentInMemory = true;
745 0 : loadInProgress = false;
746 : }
747 0 : }
748 : /**
749 : * Reads and parses a file containing a representation of a CalDelayTable as those produced by the toFile method.
750 : * This table is populated with the result of the parsing.
751 : * @param directory The name of the directory containing the file te be read and parsed.
752 : * @throws ConversionException If any error occurs while reading the
753 : * files in the directory or parsing them.
754 : *
755 : */
756 : void setFromFile(const std::string& directory);
757 :
758 : };
759 :
760 : } // End namespace asdm
761 :
762 : #endif /* CalDelayTable_CLASS */
|