CARMA C++
CorrelatorBaseline.h
Go to the documentation of this file.
1 #ifndef CORRELATORBASELINE_H
2 #define CORRELATORBASELINE_H
3 
4 #include <vector>
8 #include "carma/correlator/lib/CorrelatorPolarization.h"
9 
15 namespace carma {
16  namespace correlator {
17  namespace lib {
18 
19  class CorrelatorBaseline;
20 
21  typedef ::std::vector< CorrelatorBaseline > BaselineVector;
22 
27  public:
28 
32  explicit CorrelatorBaseline();
33 
38 
42  virtual ~CorrelatorBaseline();
43 
47  void swap( CorrelatorBaseline & rhs );
48 
53  void mySerialize( char * byteArray, int * offset ) const;
54 
58  void deserializeVer0( const char * byteArray,
59  int * offset,
60  int byteArraySize );
61 
62  void deserializeVer1( const char * byteArray,
63  int * offset,
64  int byteArraySize );
65 
69  void deserializeSwapVer0( const char * byteArray,
70  int * offset,
71  int byteArraySize );
72 
73  void deserializeSwapVer1( const char * byteArray,
74  int * offset,
75  int byteArraySize );
76 
81  void normalize();
82 
86  int getSizeInBytes() const;
87 
91  void setInput1Number(int i1num);
92 
93  void setAnt1Number(int a1num);
97  int getInput1Number() const;
98 
99  int getAnt1Number() const;
100 
104  void setInput2Number(int i2num);
105 
106  void setAnt2Number(int a2num);
107 
111  int getInput2Number() const;
112 
113  int getAnt2Number() const;
114 
118  void setBoardId(int boardId);
119 
123  int getBoardId() const;
124 
128  void setBoardSN(int boardSN);
129 
133  int getBoardSN() const;
134 
138  int getNumberOfSidebands() const;
139 
144 
150  getUpperSideband() const;
151 
157  getLowerSideband() const;
158 
164  getAutoSideband() const;
165 
170  const std::vector<carma::correlator::lib::CorrelatorSideband> &
171  getSidebands() const;
172 
173  std::vector<carma::correlator::lib::CorrelatorSideband> &
174  getSidebands();
175 
180  void flagData( unsigned int reason );
181 
186  void blankData( unsigned int reason );
187 
188  // Deprecated - underlying data is no longer set.
190  getBlankFlagStatusDEPRECATED() const;
191 
195  bool isValid( ) const;
196 
197 
201  friend bool operator==( const CorrelatorBaseline & lhs,
202  const CorrelatorBaseline & rhs ) {
203  return (lhs.getInput1Number() == rhs.getInput1Number() &&
204  lhs.getInput2Number() == rhs.getInput2Number());
205  }
206 
211 
215  void addIn( const CorrelatorBaseline & rhs );
216 
220  void setAntPol1( int antNum, carma::correlator::lib::Polarization polarization );
221 
222  void setAntPol2( int antNum, carma::correlator::lib::Polarization polarization );
223 
227  Polarization getPolarization1() const;
228 
229  Polarization getPolarization2() const;
230 
231  std::string getPolarization1String() const;
232 
233  std::string getPolarization2String() const;
234 
235  std::string getPolarization() const;
236 
237  AntNoPolPair getAntPol1() const;
238  AntNoPolPair getAntPol2() const;
239 
240  std::string getSummary() const;
241 
242 
243  bool containsSideband( CorrelatorSideband::Flavor flavor ) const;
244 
245 private:
247  getSideband( CorrelatorSideband::Flavor flavor );
248 
249  void packSidebands( char * byteArray, int * offset ) const;
250  void assign(const CorrelatorBaseline& cb);
251 
252  void setPolarization1( const carma::correlator::lib::Polarization polarization );
253 
254  void setPolarization2( const carma::correlator::lib::Polarization polarization );
255 
256  int ant1Number_;
257  int ant2Number_;
258  int input1Number_;
259  int input2Number_;
260  int boardId_;
261  int boardSN_;
262  carma::correlator::lib::Polarization polarization1_;
263  carma::correlator::lib::Polarization polarization2_;
264 
266  ::std::vector< CorrelatorSideband > sidebands_;
267  }; // End class CorrelatorBaseline
268 
269  } // End namespace lib
270  } // End namespace correlator
271 } // End namespace carma
272 
273 
274 inline
276 ant1Number_( -1 ),
277 ant2Number_( -1 ),
278 input1Number_( 0 ),
279 input2Number_( 0 ),
280 boardId_( 0 ),
281 boardSN_( 0 ),
282 polarization1_(RIGHT_POL),
283 polarization2_(RIGHT_POL),
284 bfStatusObsolete_( monitor::MonitorPoint::OK ),
285 sidebands_()
286 {
287 }
288 
289 
290 inline void
292 {
293  ::std::swap( ant1Number_, rhs.ant1Number_ );
294  ::std::swap( ant2Number_, rhs.ant2Number_ );
295  ::std::swap( input1Number_, rhs.input1Number_ );
296  ::std::swap( input2Number_, rhs.input2Number_ );
297  ::std::swap( boardId_, rhs.boardId_ );
298  ::std::swap( boardSN_, rhs.boardSN_ );
299  ::std::swap( bfStatusObsolete_, rhs.bfStatusObsolete_ );
300  sidebands_.swap( rhs.sidebands_ );
301  ::std::swap( polarization1_, rhs.polarization1_ );
302  ::std::swap( polarization2_, rhs.polarization2_ );
303 }
304 
305 
306 inline int
308 {
309  return input1Number_;
310 }
311 
312 inline int
313 carma::correlator::lib::CorrelatorBaseline::getAnt1Number( ) const
314 {
315  return ant1Number_;
316 }
317 
318 inline int
320 {
321  return input2Number_;
322 }
323 
324 inline int
325 carma::correlator::lib::CorrelatorBaseline::getAnt2Number( ) const
326 {
327  return ant2Number_;
328 }
329 
330 inline int
332 {
333  return boardId_;
334 }
335 
336 
337 inline int
339 {
340  return boardSN_;
341 }
342 
343 
344 inline int
346 {
347  return sidebands_.size();
348 }
349 
351 carma::correlator::lib::CorrelatorBaseline::getBlankFlagStatusDEPRECATED( ) const
352 {
353  return bfStatusObsolete_;
354 }
355 
356 inline const ::std::vector< carma::correlator::lib::CorrelatorSideband > &
358 {
359  return sidebands_;
360 }
361 
362 
363 inline ::std::vector< carma::correlator::lib::CorrelatorSideband > &
365 {
366  return sidebands_;
367 }
368 
369 
370 inline void
372 {
373  input1Number_ = i1num;
374 }
375 
376 inline void
377 carma::correlator::lib::CorrelatorBaseline::setAnt1Number( const int a1num )
378 {
379  ant1Number_ = a1num;
380 }
381 
382 inline void
384 {
385  input2Number_ = i2num;
386 }
387 
388 inline void
389 carma::correlator::lib::CorrelatorBaseline::setAnt2Number( const int a2num )
390 {
391  ant2Number_ = a2num;
392 }
393 
394 inline void
396 {
397  boardId_ = boardId;
398 }
399 
400 inline void
402 {
403  boardSN_ = boardSN;
404 }
405 
406 inline void
408 {
409  for( unsigned int i = 0; i < sidebands_.size(); i++ ) {
410  sidebands_.at(i).flagData( reason );
411  }
412 }
413 
414 inline void
416 {
417  for( unsigned int i = 0; i < sidebands_.size(); i++ ) {
418  sidebands_.at(i).blankData( reason );
419  }
420 }
421 
422 inline void
423 carma::correlator::lib::CorrelatorBaseline::setPolarization1(
424  const carma::correlator::lib::Polarization polarization)
425 {
426  polarization1_ = polarization;
427 }
428 
429 inline void
430 carma::correlator::lib::CorrelatorBaseline::setPolarization2(
431  const carma::correlator::lib::Polarization polarization)
432 {
433  polarization2_ = polarization;
434 }
435 
436 inline void
438  const int antNum, const carma::correlator::lib::Polarization polarization ){
439  setAnt1Number(antNum);
440  setPolarization1(polarization);
441 }
442 
443 inline void
444 carma::correlator::lib::CorrelatorBaseline::setAntPol2(
445  const int antNum, const carma::correlator::lib::Polarization polarization ){
446  setAnt2Number(antNum);
447  setPolarization2(polarization);
448 }
449 
450 inline carma::correlator::lib::Polarization
452 {
453  return polarization1_;
454 }
455 
456 
457 inline carma::correlator::lib::Polarization
458 carma::correlator::lib::CorrelatorBaseline::getPolarization2( ) const
459 {
460  return polarization2_;
461 }
462 
463 inline carma::correlator::lib::AntNoPolPair
464 carma::correlator::lib::CorrelatorBaseline::getAntPol1( ) const
465 {
466  return AntNoPolPair( ant1Number_, polarization1_ );
467 }
468 
469 inline carma::correlator::lib::AntNoPolPair
470 carma::correlator::lib::CorrelatorBaseline::getAntPol2( ) const
471 {
472  return AntNoPolPair( ant2Number_, polarization2_ );
473 }
474 
475 inline std::string
476 carma::correlator::lib::CorrelatorBaseline::getPolarization1String( ) const
477 {
478  if(polarization1_ == LEFT_POL){
479  return "L";
480  }
481  else if(polarization1_ == RIGHT_POL){
482  return "R";
483  }
484  else if(polarization1_ == HORIZONTAL_POL){
485  return "X";
486  }
487  else if(polarization1_ == VERTICAL_POL){
488  return "Y";
489  }
490  return "NONE";
491 }
492 
493 inline std::string
494 carma::correlator::lib::CorrelatorBaseline::getPolarization2String( ) const
495 {
496  if(polarization2_ == LEFT_POL){
497  return "L";
498  }
499  else if(polarization2_ == RIGHT_POL){
500  return "R";
501  }
502  else if(polarization2_ == HORIZONTAL_POL){
503  return "X";
504  }
505  else if(polarization2_ == VERTICAL_POL){
506  return "Y";
507  }
508  return "NONE";
509 }
510 
511 inline std::string
512 carma::correlator::lib::CorrelatorBaseline::getPolarization( ) const
513 {
514  std::string output = "";
515  if(polarization1_ == LEFT_POL){
516  output += "L";
517  }
518  else if(polarization1_ == RIGHT_POL){
519  output += "R";
520  }
521  else if(polarization1_ == HORIZONTAL_POL){
522  output += "X";
523  }
524  else if(polarization1_ == VERTICAL_POL){
525  output += "Y";
526  }
527  else{
528  return "NONE";
529  }
530  if(polarization2_ == LEFT_POL){
531  output += "L";
532  }
533  else if(polarization2_ == RIGHT_POL){
534  output += "R";
535  }
536  else if(polarization2_ == HORIZONTAL_POL){
537  output += "X";
538  }
539  else if(polarization2_ == VERTICAL_POL){
540  output += "Y";
541  }
542  else{
543  return "NONE";
544  }
545  return output;
546 }
547 
548 #endif
int getBoardId() const
Get the board ID from which this data came from.
void addSideband(const carma::correlator::lib::CorrelatorSideband &sb)
Add a sideband object to this baseline.
Abstract Class used to allow object to serialize themselves into a byte array.
Definition: Serializable.h:32
const carma::correlator::lib::CorrelatorSideband & getUpperSideband() const
Get an UpperSideband object.
Abstract base class for all monitor points.
void addIn(const CorrelatorBaseline &rhs)
Add a CorrelatorBaseline into this one.
friend bool operator==(const CorrelatorBaseline &lhs, const CorrelatorBaseline &rhs)
== operator.
Polarization getPolarization1() const
Get polarization.
int getBoardSN() const
Get the Board serial number from which this data came from.
void setAntPol1(int antNum, carma::correlator::lib::Polarization polarization)
Set polarization &amp; antenna number.
BLANKING_FLAGGING
Blanking/flagging status of the data.
Definition: MonitorPoint.h:159
void setInput2Number(int i2num)
Set the second input number for this baseline.
const std::vector< carma::correlator::lib::CorrelatorSideband > & getSidebands() const
Get all sidebands stored for this baseline.
CorrelatorBaseline & operator=(const CorrelatorBaseline &rhs)
= operator.
int getInput1Number() const
Get the first input number for this baseline.
void swap(CorrelatorBaseline &rhs)
Swap this instance with another CorrelatorBaseline instance.
void setInput1Number(int i1num)
Set the first input number for this baseline.
bool isValid() const
Returns true if any sideband is valid, false otherwise.
int getSizeInBytes() const
Return size in bytes.
void flagData(unsigned int reason)
Flag data with specified reason.
const carma::correlator::lib::CorrelatorSideband & getLowerSideband() const
Get a LowerSideband object.
Class to hold Correlator Baseline data.
void mySerialize(char *byteArray, int *offset) const
Called by serialize method.
void blankData(unsigned int reason)
Blank data with specified reason (removes all data).
void setBoardId(int boardId)
Set the board ID from which this data came from.
int getNumberOfSidebands() const
Get the number of Sidebands for this baseline.
const carma::correlator::lib::CorrelatorSideband & getAutoSideband() const
Get an AutoSideband object.
void normalize()
Normalize baseline data.
void deserializeSwapVer0(const char *byteArray, int *offset, int byteArraySize)
call to reconstruct the object.
void setBoardSN(int boardSN)
Set the Board serial number from which this data came from.
int getInput2Number() const
Get the second input number for this baseline.
void deserializeVer0(const char *byteArray, int *offset, int byteArraySize)
call to reconstruct the object.
Base class for Correlator Sideband data.