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 PointingTable.h
32 : */
33 :
34 : #ifndef PointingTable_CLASS
35 : #define PointingTable_CLASS
36 :
37 : #include <string>
38 : #include <vector>
39 : #include <map>
40 :
41 :
42 :
43 :
44 : #include <alma/ASDM/ArrayTimeInterval.h>
45 :
46 :
47 :
48 : #include <alma/ASDM/Angle.h>
49 :
50 :
51 :
52 : #include <alma/ASDM/ArrayTime.h>
53 :
54 :
55 :
56 : #include <alma/ASDM/Tag.h>
57 :
58 :
59 :
60 :
61 :
62 :
63 :
64 :
65 :
66 :
67 :
68 :
69 :
70 :
71 :
72 :
73 :
74 :
75 :
76 :
77 :
78 :
79 :
80 :
81 :
82 :
83 :
84 :
85 :
86 :
87 : #include <alma/Enumerations/CDirectionReferenceCode.h>
88 :
89 :
90 :
91 :
92 :
93 :
94 :
95 :
96 :
97 :
98 : #include <alma/ASDM/ConversionException.h>
99 : #include <alma/ASDM/DuplicateKey.h>
100 : #include <alma/ASDM/UniquenessViolationException.h>
101 : #include <alma/ASDM/NoSuchRow.h>
102 : #include <alma/ASDM/DuplicateKey.h>
103 :
104 :
105 : #ifndef WITHOUT_ACS
106 : #include <asdmIDLC.h>
107 : #endif
108 :
109 : #include <alma/ASDM/Representable.h>
110 :
111 : #include <pthread.h>
112 :
113 : namespace asdm {
114 :
115 : //class asdm::ASDM;
116 : //class asdm::PointingRow;
117 :
118 : class ASDM;
119 : class PointingRow;
120 : /**
121 : * The PointingTable class is an Alma table.
122 : * <BR>
123 : *
124 : * \par Role
125 : * Antenna pointing information.
126 : * <BR>
127 :
128 : * Generated from model's revision "-1", branch ""
129 : *
130 : * <TABLE BORDER="1">
131 : * <CAPTION> Attributes of Pointing </CAPTION>
132 : * <TR BGCOLOR="#AAAAAA"> <TH> Name </TH> <TH> Type </TH> <TH> Expected shape </TH> <TH> Comment </TH></TR>
133 :
134 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" align="center"> Key </TD></TR>
135 :
136 : * <TR>
137 :
138 : * <TD> antennaId </TD>
139 :
140 : * <TD> Tag</TD>
141 : * <TD> </TD>
142 : * <TD> refers to a unique row in AntennaTable. </TD>
143 : * </TR>
144 :
145 : * <TR>
146 :
147 : * <TD> timeInterval </TD>
148 :
149 : * <TD> ArrayTimeInterval</TD>
150 : * <TD> </TD>
151 : * <TD> the time interval of validity of the row's content. </TD>
152 : * </TR>
153 :
154 :
155 :
156 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Mandatory) </TH></TR>
157 :
158 : * <TR>
159 : * <TD> numSample (numSample)</TD>
160 : * <TD> int </TD>
161 : * <TD> </TD>
162 : * <TD> the number of time samples. </TD>
163 : * </TR>
164 :
165 : * <TR>
166 : * <TD> encoder </TD>
167 : * <TD> std::vector<std::vector<Angle > > </TD>
168 : * <TD> numSample, 2 </TD>
169 : * <TD> Encoder values </TD>
170 : * </TR>
171 :
172 : * <TR>
173 : * <TD> pointingTracking </TD>
174 : * <TD> bool </TD>
175 : * <TD> </TD>
176 : * <TD> the antenna was in tracking mode (true) or not (false). </TD>
177 : * </TR>
178 :
179 : * <TR>
180 : * <TD> usePolynomials </TD>
181 : * <TD> bool </TD>
182 : * <TD> </TD>
183 : * <TD> use polynomials expansions (true) or not (false). </TD>
184 : * </TR>
185 :
186 : * <TR>
187 : * <TD> timeOrigin </TD>
188 : * <TD> ArrayTime </TD>
189 : * <TD> </TD>
190 : * <TD> the value used as origin in the polynomials expansions. </TD>
191 : * </TR>
192 :
193 : * <TR>
194 : * <TD> numTerm (numTerm)</TD>
195 : * <TD> int </TD>
196 : * <TD> </TD>
197 : * <TD> the number of terms of the polynomials. </TD>
198 : * </TR>
199 :
200 : * <TR>
201 : * <TD> pointingDirection </TD>
202 : * <TD> std::vector<std::vector<Angle > > </TD>
203 : * <TD> numTerm, 2 </TD>
204 : * <TD> the commanded pointing direction. </TD>
205 : * </TR>
206 :
207 : * <TR>
208 : * <TD> target </TD>
209 : * <TD> std::vector<std::vector<Angle > > </TD>
210 : * <TD> numTerm, 2 </TD>
211 : * <TD> the direction of the target. </TD>
212 : * </TR>
213 :
214 : * <TR>
215 : * <TD> offset </TD>
216 : * <TD> std::vector<std::vector<Angle > > </TD>
217 : * <TD> numTerm, 2 </TD>
218 : * <TD> Horizon mapping offsets </TD>
219 : * </TR>
220 :
221 : * <TR>
222 : * <TD> pointingModelId </TD>
223 : * <TD> int </TD>
224 : * <TD> </TD>
225 : * <TD> refers to a collection of rows in PointingModelTable. </TD>
226 : * </TR>
227 :
228 :
229 :
230 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Optional) </TH></TR>
231 :
232 : * <TR>
233 : * <TD> overTheTop</TD>
234 : * <TD> bool </TD>
235 : * <TD> </TD>
236 : * <TD> pointing ar elevations larger than 90 degrees (true) or lower (false). </TD>
237 : * </TR>
238 :
239 : * <TR>
240 : * <TD> sourceOffset</TD>
241 : * <TD> std::vector<std::vector<Angle > > </TD>
242 : * <TD> numTerm, 2 </TD>
243 : * <TD> sources offsets (one pair per term of the polynomial). </TD>
244 : * </TR>
245 :
246 : * <TR>
247 : * <TD> sourceOffsetReferenceCode</TD>
248 : * <TD> DirectionReferenceCodeMod::DirectionReferenceCode </TD>
249 : * <TD> </TD>
250 : * <TD> the direction reference code associated to the source offset. </TD>
251 : * </TR>
252 :
253 : * <TR>
254 : * <TD> sourceOffsetEquinox</TD>
255 : * <TD> ArrayTime </TD>
256 : * <TD> </TD>
257 : * <TD> the equinox information (if needed by sourceReferenceCode). </TD>
258 : * </TR>
259 :
260 : * <TR>
261 : * <TD> sampledTimeInterval</TD>
262 : * <TD> std::vector<ArrayTimeInterval > </TD>
263 : * <TD> numSample </TD>
264 : * <TD> an array of ArrayTimeInterval which must be given explicitly as soon as the data are irregularily sampled. </TD>
265 : * </TR>
266 :
267 : * <TR>
268 : * <TD> atmosphericCorrection</TD>
269 : * <TD> std::vector<std::vector<Angle > > </TD>
270 : * <TD> numTerm, 2 </TD>
271 : * <TD> This is the correction applied to the commanded position to take into account refraction and any other atmospheric effects. This term will always be zero if there is no atmosphere. For ALMA this is the atmospheric refraction correction and will result in a correction in just the elevation axis. </TD>
272 : * </TR>
273 :
274 :
275 : * </TABLE>
276 : */
277 : class PointingTable : public Representable {
278 : friend class ASDM;
279 :
280 : public:
281 :
282 :
283 : /**
284 : * Return the list of field names that make up key key
285 : * as an array of strings.
286 : * @return a vector of string.
287 : */
288 : static const std::vector<std::string>& getKeyName();
289 :
290 :
291 : virtual ~PointingTable();
292 :
293 : /**
294 : * Return the container to which this table belongs.
295 : *
296 : * @return the ASDM containing this table.
297 : */
298 : ASDM &getContainer() const;
299 :
300 : /**
301 : * Return the number of rows in the table.
302 : *
303 : * @return the number of rows in an unsigned int.
304 : */
305 : unsigned int size() const;
306 :
307 : /**
308 : * Return the name of this table.
309 : *
310 : * This is a instance method of the class.
311 : *
312 : * @return the name of this table in a string.
313 : */
314 : std::string getName() const;
315 :
316 : /**
317 : * Return the name of this table.
318 : *
319 : * This is a static method of the class.
320 : *
321 : * @return the name of this table in a string.
322 : */
323 : static std::string name() ;
324 :
325 : /**
326 : * Return the version information about this table.
327 : *
328 : */
329 : std::string getVersion() const ;
330 :
331 : /**
332 : * Return the names of the attributes of this table.
333 : *
334 : * @return a vector of string
335 : */
336 : static const std::vector<std::string>& getAttributesNames();
337 :
338 : /**
339 : * Return the default sorted list of attributes names in the binary representation of the table.
340 : *
341 : * @return a const reference to a vector of string
342 : */
343 : static const std::vector<std::string>& defaultAttributesNamesInBin();
344 :
345 : /**
346 : * Return this table's Entity.
347 : */
348 : Entity getEntity() const;
349 :
350 : /**
351 : * Set this table's Entity.
352 : * @param e An entity.
353 : */
354 : void setEntity(Entity e);
355 :
356 : /**
357 : * Produces an XML representation conform
358 : * to the schema defined for Pointing (PointingTable.xsd).
359 : *
360 : * @returns a string containing the XML representation.
361 : * @throws ConversionException
362 : */
363 : std::string toXML() ;
364 :
365 : #ifndef WITHOUT_ACS
366 : // Conversion Methods
367 : /**
368 : * Convert this table into a PointingTableIDL CORBA structure.
369 : *
370 : * @return a pointer to a PointingTableIDL
371 : */
372 : asdmIDL::PointingTableIDL *toIDL() ;
373 :
374 : /**
375 : * Fills the CORBA data structure passed in parameter
376 : * with the content of this table.
377 : *
378 : * @param x a reference to the asdmIDL::PointingTableIDL to be populated
379 : * with the content of this.
380 : */
381 : void toIDL(asdmIDL::PointingTableIDL& x) const;
382 :
383 : #endif
384 :
385 : #ifndef WITHOUT_ACS
386 : /**
387 : * Populate this table from the content of a PointingTableIDL Corba structure.
388 : *
389 : * @throws DuplicateKey Thrown if the method tries to add a row having a key that is already in the table.
390 : * @throws ConversionException
391 : */
392 : void fromIDL(asdmIDL::PointingTableIDL x) ;
393 : #endif
394 :
395 : //
396 : // ====> Row creation.
397 : //
398 :
399 : /**
400 : * Create a new row with default values.
401 : * @return a pointer on a PointingRow
402 : */
403 : PointingRow *newRow();
404 :
405 :
406 : /**
407 : * Create a new row initialized to the specified values.
408 : * @return a pointer on the created and initialized row.
409 :
410 : * @param antennaId
411 :
412 : * @param timeInterval
413 :
414 : * @param numSample
415 :
416 : * @param encoder
417 :
418 : * @param pointingTracking
419 :
420 : * @param usePolynomials
421 :
422 : * @param timeOrigin
423 :
424 : * @param numTerm
425 :
426 : * @param pointingDirection
427 :
428 : * @param target
429 :
430 : * @param offset
431 :
432 : * @param pointingModelId
433 :
434 : */
435 : PointingRow *newRow(Tag antennaId, ArrayTimeInterval timeInterval, int numSample, std::vector<std::vector<Angle > > encoder, bool pointingTracking, bool usePolynomials, ArrayTime timeOrigin, int numTerm, std::vector<std::vector<Angle > > pointingDirection, std::vector<std::vector<Angle > > target, std::vector<std::vector<Angle > > offset, int pointingModelId);
436 :
437 :
438 :
439 : /**
440 : * Create a new row using a copy constructor mechanism.
441 : *
442 : * The method creates a new PointingRow owned by this. Each attribute of the created row
443 : * is a (deep) copy of the corresponding attribute of row. The method does not add
444 : * the created row to this, its simply parents it to this, a call to the add method
445 : * has to be done in order to get the row added (very likely after having modified
446 : * some of its attributes).
447 : * If row is null then the method returns a new PointingRow with default values for its attributes.
448 : *
449 : * @param row the row which is to be copied.
450 : */
451 : PointingRow *newRow(PointingRow *row);
452 :
453 : //
454 : // ====> Append a row to its table.
455 : //
456 :
457 :
458 : /**
459 : * Add a row.
460 : * @param x a pointer to the PointingRow to be added.
461 : *
462 : * @return a pointer to a PointingRow. If the table contains a PointingRow whose attributes (key and mandatory values) are equal to x ones
463 : * then returns a pointer on that PointingRow, otherwise returns x.
464 : *
465 : * @throw DuplicateKey { thrown when the table contains a PointingRow with a key equal to the x one but having
466 : * and a value section different from x one }
467 : *
468 :
469 : * @note The row is inserted in the table in such a way that all the rows having the same value of
470 : * ( antennaId ) are stored by ascending time.
471 : * @see method getByContext.
472 :
473 : */
474 : PointingRow* add(PointingRow* x) ;
475 :
476 :
477 :
478 :
479 :
480 : //
481 : // ====> Methods returning rows.
482 : //
483 :
484 : /**
485 : * Get a collection of pointers on the rows of the table.
486 : * @return Alls rows in a vector of pointers of PointingRow. The elements of this vector are stored in the order
487 : * in which they have been added to the PointingTable.
488 : */
489 : std::vector<PointingRow *> get() ;
490 :
491 : /**
492 : * Get a const reference on the collection of rows pointers internally hold by the table.
493 : * @return A const reference of a vector of pointers of PointingRow. The elements of this vector are stored in the order
494 : * in which they have been added to the PointingTable.
495 : *
496 : */
497 : const std::vector<PointingRow *>& get() const ;
498 :
499 :
500 : /**
501 : * Returns all the rows sorted by ascending startTime for a given context.
502 : * The context is defined by a value of ( antennaId ).
503 : *
504 : * @return a pointer on a vector<PointingRow *>. A null returned value means that the table contains
505 : * no PointingRow for the given ( antennaId ).
506 : *
507 : * @throws IllegalAccessException when a call is done to this method when it's called while the dataset has been imported with the
508 : * option checkRowUniqueness set to false.
509 : */
510 : std::vector <PointingRow*> *getByContext(Tag antennaId);
511 :
512 :
513 :
514 :
515 :
516 : /**
517 : * Returns a PointingRow* given a key.
518 : * @return a pointer to the row having the key whose values are passed as parameters, or 0 if
519 : * no row exists for that key.
520 :
521 : * @param antennaId
522 :
523 : * @param timeInterval
524 :
525 : *
526 : */
527 : PointingRow* getRowByKey(Tag antennaId, ArrayTimeInterval timeInterval);
528 :
529 :
530 :
531 :
532 :
533 : /**
534 : * Look up the table for a row whose all attributes
535 : * are equal to the corresponding parameters of the method.
536 : * @return a pointer on this row if any, null otherwise.
537 : *
538 :
539 : * @param antennaId
540 :
541 : * @param timeInterval
542 :
543 : * @param numSample
544 :
545 : * @param encoder
546 :
547 : * @param pointingTracking
548 :
549 : * @param usePolynomials
550 :
551 : * @param timeOrigin
552 :
553 : * @param numTerm
554 :
555 : * @param pointingDirection
556 :
557 : * @param target
558 :
559 : * @param offset
560 :
561 : * @param pointingModelId
562 :
563 : */
564 : PointingRow* lookup(Tag antennaId, ArrayTimeInterval timeInterval, int numSample, std::vector<std::vector<Angle > > encoder, bool pointingTracking, bool usePolynomials, ArrayTime timeOrigin, int numTerm, std::vector<std::vector<Angle > > pointingDirection, std::vector<std::vector<Angle > > target, std::vector<std::vector<Angle > > offset, int pointingModelId);
565 :
566 :
567 : void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
568 : BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
569 :
570 : private:
571 :
572 : /**
573 : * Create a PointingTable.
574 : * <p>
575 : * This constructor is private because only the
576 : * container can create tables. All tables must know the container
577 : * to which they belong.
578 : * @param container The container to which this table belongs.
579 : */
580 : PointingTable (ASDM & container);
581 :
582 : ASDM & container;
583 :
584 : bool archiveAsBin; // If true archive binary else archive XML
585 : bool fileAsBin ; // If true file binary else file XML
586 :
587 : std::string version ;
588 :
589 : Entity entity;
590 :
591 :
592 :
593 :
594 :
595 :
596 : /**
597 : * If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and throw exception if not.
598 : * Check if *x verifies the key uniqueness rule and throw an exception if not.
599 : * Append x to its table.
600 : * @throws DuplicateKey
601 :
602 : */
603 : PointingRow* checkAndAdd(PointingRow* x, bool skipCheckUniqueness=false) ;
604 :
605 : /**
606 : * Brutally append an PointingRow x to the collection of rows already stored in this table. No uniqueness check is done !
607 : *
608 : * @param PointingRow* x a pointer onto the PointingRow to be appended.
609 : */
610 : void append(PointingRow* x) ;
611 :
612 : /**
613 : * Brutally append an PointingRow x to the collection of rows already stored in this table. No uniqueness check is done !
614 : *
615 : * @param PointingRow* x a pointer onto the PointingRow to be appended.
616 : */
617 : void addWithoutCheckingUnique(PointingRow* x) ;
618 :
619 :
620 :
621 :
622 :
623 :
624 : /**
625 : * Insert a PointingRow* in a vector of PointingRow* so that it's ordered by ascending time.
626 : *
627 : * @param PointingRow* x . The pointer to be inserted.
628 : * @param vector <PointingRow*>& row . A reference to the vector where to insert x.
629 : *
630 : */
631 : PointingRow * insertByStartTime(PointingRow* x, std::vector<PointingRow* >& row);
632 :
633 :
634 :
635 : // A data structure to store the pointers on the table's rows.
636 :
637 : // In all cases we maintain a private vector of PointingRow s.
638 : std::vector<PointingRow * > privateRows;
639 :
640 :
641 :
642 :
643 :
644 :
645 :
646 :
647 : typedef std::vector <PointingRow* > TIME_ROWS;
648 : std::map<std::string, TIME_ROWS > context;
649 :
650 : /**
651 : * Returns a string built by concatenating the ascii representation of the
652 : * parameters values suffixed with a "_" character.
653 : */
654 : std::string Key(Tag antennaId) ;
655 :
656 :
657 :
658 :
659 : /**
660 : * Fills the vector vout (passed by reference) with pointers on elements of vin
661 : * whose attributes are equal to the corresponding parameters of the method.
662 : *
663 : */
664 : void getByKeyNoAutoIncNoTime(std::vector <PointingRow*>& vin, std::vector <PointingRow*>& vout, Tag antennaId);
665 :
666 :
667 :
668 : void error() ; //throw(ConversionException);
669 :
670 :
671 : /**
672 : * Populate this table from the content of a XML document that is required to
673 : * be conform to the XML schema defined for a Pointing (PointingTable.xsd).
674 : * @throws ConversionException
675 : *
676 : */
677 : void fromXML(std::string& xmlDoc) ;
678 :
679 : std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
680 :
681 : /**
682 : * Private methods involved during the build of this table out of the content
683 : * of file(s) containing an external representation of a Pointing table.
684 : */
685 : void setFromMIMEFile(const std::string& directory);
686 : /*
687 : void openMIMEFile(const std::string& directory);
688 : */
689 : void setFromXMLFile(const std::string& directory);
690 :
691 : /**
692 : * Serialize this into a stream of bytes and encapsulates that stream into a MIME message.
693 : * @returns a string containing the MIME message.
694 : *
695 : * @param byteOrder a const pointer to a static instance of the class ByteOrder.
696 : *
697 : */
698 : std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
699 :
700 :
701 : /**
702 : * Extracts the binary part of a MIME message and deserialize its content
703 : * to fill this with the result of the deserialization.
704 : * @param mimeMsg the string containing the MIME message.
705 : * @throws ConversionException
706 : */
707 : void setFromMIME(const std::string & mimeMsg);
708 :
709 : /**
710 : * Private methods involved during the export of this table into disk file(s).
711 : */
712 : std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
713 :
714 : /**
715 : * Stores a representation (binary or XML) of this table into a file.
716 : *
717 : * Depending on the boolean value of its private field fileAsBin a binary serialization of this (fileAsBin==true)
718 : * will be saved in a file "Pointing.bin" or an XML representation (fileAsBin==false) will be saved in a file "Pointing.xml".
719 : * The file is always written in a directory whose name is passed as a parameter.
720 : * @param directory The name of directory where the file containing the table's representation will be saved.
721 : *
722 : */
723 : void toFile(std::string directory);
724 :
725 : /**
726 : * Load the table in memory if necessary.
727 : */
728 : bool loadInProgress;
729 58 : void checkPresenceInMemory() {
730 58 : if (!presentInMemory && !loadInProgress) {
731 44 : loadInProgress = true;
732 44 : setFromFile(getContainer().getDirectory());
733 44 : presentInMemory = true;
734 44 : loadInProgress = false;
735 : }
736 58 : }
737 : /**
738 : * Reads and parses a file containing a representation of a PointingTable as those produced by the toFile method.
739 : * This table is populated with the result of the parsing.
740 : * @param directory The name of the directory containing the file te be read and parsed.
741 : * @throws ConversionException If any error occurs while reading the
742 : * files in the directory or parsing them.
743 : *
744 : */
745 : void setFromFile(const std::string& directory);
746 :
747 : };
748 :
749 : } // End namespace asdm
750 :
751 : #endif /* PointingTable_CLASS */
|