LCOV - code coverage report
Current view: top level - alma/ASDM - ArrayTimeInterval.cc (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 28 82 34.1 %
Date: 2023-11-06 10:06:49 Functions: 6 13 46.2 %

          Line data    Source code
       1             : #include <alma/ASDM/ArrayTimeInterval.h>
       2             : 
       3             : using namespace std;
       4             : 
       5             : namespace asdm {
       6             :   
       7             :   bool ArrayTimeInterval::readStartTimeDurationInBin_ = false;
       8             :   bool ArrayTimeInterval::readStartTimeDurationInXML_ = false;
       9             : 
      10             : #ifndef WITHOUT_ACS
      11             :   /**
      12             :    * Create a ArrayTimeInterval from an IDLArrayTimeInterval object.
      13             :    * @param t The IDL ArrayTimeInterval object.
      14             :    */
      15             :   ArrayTimeInterval::ArrayTimeInterval (asdmIDLTypes::IDLArrayTimeInterval t) {
      16             :     start = ArrayTime(t.start);
      17             :     duration = Interval(t.duration); 
      18             :   }
      19             :   
      20             :   // inline to IDL conversion.
      21             :   const asdmIDLTypes::IDLArrayTimeInterval ArrayTimeInterval::toIDLArrayTimeInterval()const {
      22             :     asdmIDLTypes::IDLArrayTimeInterval x;
      23             :     x.start = start.get();
      24             :     x.duration = duration.get();
      25             :     return x;
      26             :   }
      27             : #endif
      28             : 
      29       28561 :   void ArrayTimeInterval::toBin(EndianOSStream& eoss) const {
      30       28561 :     int64_t start = getStart().get();
      31       28561 :     int64_t midpoint = start + getDuration().get() / 2;
      32       28561 :     eoss.writeLongLong(midpoint);
      33       28561 :     eoss.writeLongLong(duration.get());
      34       28561 :   }
      35             : 
      36           0 :   void ArrayTimeInterval::toBin(const vector<ArrayTimeInterval>& arrayTimeInterval,  EndianOSStream& eoss) {
      37           0 :     eoss.writeInt((int) arrayTimeInterval.size());
      38           0 :     for (unsigned int i = 0; i < arrayTimeInterval.size(); i++) {
      39           0 :       arrayTimeInterval.at(i).toBin(eoss);
      40             :     }
      41           0 :   }
      42             : 
      43           0 :   void ArrayTimeInterval::toBin(const vector<vector<ArrayTimeInterval> >& arrayTimeInterval,  EndianOSStream& eoss) {
      44           0 :     eoss.writeInt((int) arrayTimeInterval.size());
      45           0 :     eoss.writeInt((int) arrayTimeInterval.at(0).size());
      46           0 :     for (unsigned int i = 0; i < arrayTimeInterval.size(); i++)
      47           0 :       for (unsigned int j = 0; j < arrayTimeInterval.at(0).size(); j++) {
      48           0 :         arrayTimeInterval.at(i).at(j).toBin(eoss);
      49             :       }
      50           0 :   }
      51             : 
      52           0 :   void ArrayTimeInterval::toBin(const vector< vector<vector<ArrayTimeInterval> > >& arrayTimeInterval,  EndianOSStream& eoss) {
      53           0 :     eoss.writeInt((int) arrayTimeInterval.size());
      54           0 :     eoss.writeInt((int) arrayTimeInterval.at(0).size());
      55           0 :     eoss.writeInt((int) arrayTimeInterval.at(0).at(0).size());  
      56           0 :     for (unsigned int i = 0; i < arrayTimeInterval.size(); i++)
      57           0 :       for (unsigned int j = 0; j < arrayTimeInterval.at(0).size(); j++)
      58           0 :         for (unsigned int k = 0; k < arrayTimeInterval.at(0).at(0).size(); j++) {
      59           0 :           arrayTimeInterval.at(i).at(j).at(k).toBin(eoss);
      60             :         }
      61           0 :   }
      62             : 
      63          83 :   void ArrayTimeInterval::readStartTimeDurationInBin(bool b) {
      64          83 :     readStartTimeDurationInBin_ = b;
      65          83 :   }
      66             : 
      67           0 :   bool ArrayTimeInterval::readStartTimeDurationInBin() {
      68           0 :     return readStartTimeDurationInBin_;
      69             :   }
      70             : 
      71          83 :   void ArrayTimeInterval::readStartTimeDurationInXML(bool b) {
      72          83 :     readStartTimeDurationInXML_ = b;
      73          83 :   }
      74             : 
      75      118087 :   bool ArrayTimeInterval::readStartTimeDurationInXML() {
      76      118087 :     return readStartTimeDurationInXML_;
      77             :   }
      78             : 
      79             : 
      80     4646196 :   ArrayTimeInterval ArrayTimeInterval::fromBin(EndianIStream & eis) {
      81             :     int64_t start, duration;
      82     4646196 :     if (readStartTimeDurationInBin_) {
      83       25080 :       start = eis.readLongLong();
      84       25080 :       duration = eis.readLongLong();
      85             :     }
      86             :     else {
      87     4621116 :       int64_t  midpoint = eis.readLongLong();
      88     4621116 :       duration = eis.readLongLong();
      89     4621116 :       start = midpoint - duration / 2;
      90             :     }      
      91     4646196 :     return ArrayTimeInterval(start, duration);
      92             :   }
      93             : 
      94           4 :   vector<ArrayTimeInterval> ArrayTimeInterval::from1DBin(EndianIStream & eis) {
      95           4 :     int dim1 = eis.readInt();
      96           4 :     vector<ArrayTimeInterval> result;
      97       25036 :     for (int i = 0; i < dim1; i++) {
      98       25032 :       result.push_back(fromBin(eis));
      99             :     }
     100           4 :     return result;      
     101             :   }
     102             : 
     103           0 :   vector<vector<ArrayTimeInterval > > ArrayTimeInterval::from2DBin(EndianIStream & eis) {
     104           0 :     int dim1 = eis.readInt();
     105           0 :     int dim2 = eis.readInt();
     106           0 :     vector< vector<ArrayTimeInterval> >result;
     107           0 :     vector <ArrayTimeInterval> aux;
     108           0 :     for (int i = 0; i < dim1; i++) {
     109           0 :       aux.clear();
     110           0 :       for (int j = 0; j < dim2; j++) {
     111           0 :         aux.push_back(fromBin(eis));
     112             :       }
     113           0 :       result.push_back(aux);
     114             :     }
     115           0 :     return result;      
     116             :   }
     117             : 
     118           0 :   vector<vector<vector<ArrayTimeInterval > > > ArrayTimeInterval::from3DBin(EndianIStream & eis) {
     119           0 :     int dim1 = eis.readInt();
     120           0 :     int dim2 = eis.readInt();
     121           0 :     int dim3 = eis.readInt();
     122           0 :     vector<vector< vector<ArrayTimeInterval> > >result;
     123           0 :     vector < vector<ArrayTimeInterval> >aux1;
     124           0 :     vector <ArrayTimeInterval> aux2;
     125           0 :     for (int i = 0; i < dim1; i++) {
     126           0 :       aux1.clear();
     127           0 :       for (int j = 0; j < dim2; j++) {
     128           0 :         aux2.clear();
     129           0 :         for (int k = 0; k < dim3; k++) {
     130           0 :           aux2.push_back(fromBin(eis));
     131             :         }
     132           0 :         aux1.push_back(aux2);
     133             :       }
     134           0 :       result.push_back(aux1);
     135             :     }
     136           0 :     return result;      
     137             :   }
     138             : 
     139           0 :   string ArrayTimeInterval::toString() const {
     140           0 :     ostringstream oss;
     141           0 :     oss << "start=" << start.toFITS() << ",duration=" << duration / 1.e9 << "s." ;
     142           0 :     return oss.str();
     143             :   }
     144             : } // end name space

Generated by: LCOV version 1.16