CARMA C++
CorrDataRemapperControlImpl.h
Go to the documentation of this file.
1 // $Id: CorrDataRemapperControlImpl.h,v 1.4 2014/06/20 15:56:19 mpound Exp $
2 
3 #ifndef CARMA_CORRELATOR_CORRDATAREMAPPERCONTROLIMPL_H
4 #define CARMA_CORRELATOR_CORRDATAREMAPPERCONTROLIMPL_H
5 
15 #include <vector>
16 #include <map>
17 #include <boost/shared_ptr.hpp>
18 
20 
22 
23 #include "carma/correlator/transport/CorrDataRemapperControl.h"
25 
26 #include "carma/monitor/SlRemapperSubsystem.h"
27 #include "carma/monitor/WbRemapperSubsystem.h"
28 #include "carma/monitor/C3gRemapperSubsystem.h"
29 
30 #include "carma/szautil/Mutex.h"
31 
32 #include "carma/util/Orb.h"
33 
34 // memory managed pointers, no need to delete them in class destructor
35 typedef boost::shared_ptr<carma::monitor::SlRemapperSubsystem> slmon_ptr;
36 typedef boost::shared_ptr<carma::monitor::WbRemapperSubsystem> wbmon_ptr;
37 typedef boost::shared_ptr<carma::monitor::C3gRemapperSubsystem> c3gmon_ptr;
38 
39 namespace carma {
40  namespace correlator {
41 
42  namespace lib {
43  class CorrelatorData;
44  }
45 
46  class CorrDataRemapper;
47 
48  class CorrDataRemapperControlImpl {
49  public:
50 
51  enum Sideband {
52  SB_AUTO,
53  SB_LSB,
54  SB_USB
55  };
56 
57  //------------------------------------------------------------
58  // A struct for handling debug information
59  //------------------------------------------------------------
60 
61  struct Debugger {
62 
63  // If true, print debugging output
64 
65  bool debug_;
66 
67  // Band number ro print
68 
69  unsigned astroBandNo_;
70 
71  // Sideband to print
72 
73  Sideband sideband_;
74 
75  // First and second input number to print
76 
77  unsigned inputNo1_;
78  unsigned inputNo2_;
79 
80  Debugger();
81  void printDebugInfo(carma::correlator::lib::CorrelatorData* cd);
82  void printSideband(const carma::correlator::lib::CorrelatorSideband& sb);
83  };
84 
85  //=======================================================================
86  // Define a class for producing data via notification
87  //=======================================================================
88 
89  class Producer : public carma::correlator::obsRecord2::CorbaCorrProducer {
90  public:
91 
92  Producer(std::string notificationChannelName, carma::util::Orb & orb );
93  ~Producer();
94 
95  std::string ncName_;
96 
97  void sendCorrelatorData(carma::correlator::lib::CorrelatorData* data);
98 
99  };
100 
104  CorrDataRemapperControlImpl(bool produce, std::string imrSrc, std::string imrDest, bool noPCS);
105 
109  virtual ~CorrDataRemapperControlImpl();
110 
111  //------------------------------------------------------------
112  // IDL interface
113  //------------------------------------------------------------
114 
115  void clearAstroBandInputMap(CORBA::UShort& astroBandNo);
116 
117  void updateAstroBandInputMap(CORBA::UShort& astroBandNo,
118  const CorrDataRemapperControl::AstroBandInputSeq& astroBandInputs);
119 
120  //------------------------------------------------------------
121  // Non-IDL methods
122  //------------------------------------------------------------
123 
124  // Initialize data connections
125 
126  void createProducers();
127 
128  // Create correlator-data listener resources
129 
130  void createCorrBandListeners();
131  void createAstroBandListeners();
132 
133  // Spawn correlator-data listeners
134 
135  void spawnListeners();
136  void spawnProducers();
137 
138  void addListener(std::string objectName, const unsigned bandNo);
139 
145  bool publishData(carma::correlator::lib::CorrelatorData* cd, unsigned astroBandNo);
146 
147  Debugger& getDebugger();
148 
149  void setAstroBandInputMapsToDefaults();
150 
151  // Methods to set the underlying monitor point values via callback
152  // from an instantiated CorrDataRemapper listener.
153  // First parameter is the notification channel name which is used to
154  // look up the associated monitor subsystem from the std::map.
155  // Second parameter is the monitor point value to set.
156 
163  void setOnlineMP( const std::string & ncName, const bool online );
164 
172  void setNumValidBaselinesMP( const std::string & ncName, const unsigned num );
173 
174  // There is no way for the remapper to know the number of invalid baselines
175  // because the correlator data receieved already has the invalid baselines
176  // removed.
193  void setAstrobandNoMP( const std::string & ncName, const unsigned abNo );
194 
202  void setNumConjugatedMP( const std::string & ncName, const unsigned num);
203 
210  void setPublishedObjectMP( const std::string & ncName, const std::string & objName );
211 
220  void setDefaultPublishedObjectMP( const std::string & ncName, const unsigned astroBandNo);
221 
228  void setReceivedTimeMP( const std::string & ncName, const double mjd);
229 
236  void setPublishedTimeMP( const std::string & ncName, const double mjd);
237 
238  private:
239 
240  // IMR from which we are getting our data
241 
242  std::string imrSrc_;
243 
244  // IMR on which we are publishing our data
245 
246  std::string imrDest_;
247 
248  // Debugger object for printing out information on visibility data
249 
250  Debugger debugger_;
251 
252  // If true, we will connect to the actual data stream and produce data
253  // If false, we will connect to the astroband data stream and print it
254 
255  bool produce_;
256 
257  // True if we are NOT using Program's corba::Server as the orb.
258  // In this case no monitor system can be written.
259  bool noPCS_;
260 
261  // A vector of listeners for collecting data from correlator
262  // band servers
263 
264  // @todo consider using shared_ptr here.
265  std::vector<CorrDataRemapper*> listeners_;
266 
267  // A vector of producers for publishing data on notification
268  // channels
269 
270  // @todo consider using shared_ptr here.
271  std::vector<Producer*> producers_;
272  // names of published remapped objects indexed by astroband number
273  std::map<unsigned, std::string> producerNames_;
274 
275  carma::util::Orb orb_;
276 
277  // A cleverer person would do this with a single map
278  // and a template.
279  std::map<std::string, slmon_ptr > slMonsys_;
280  std::map<std::string, wbmon_ptr > wbMonsys_;
281  std::map<std::string, c3gmon_ptr > c3gMonsys_;
282 
283 
284  }; // End class CorrDataRemapperControlImpl
285 
286  } // End namespace correlator
287 } // End namespace carma
288 
289 
290 
291 #endif // End #ifndef CARMA_CORRELATOR_CORRDATAREMAPPERCONTROLIMPL_H
Implements interface for serving correlator data using CORBA.
Tagged: Tue Feb 22 18:45:20 PST 2011.
Interface file for the CorbaCorrProducer class.
Class used to represents bands of Correlator Data.
Tagged: Mon Feb 14 17:11:13 PST 2011.
Tagged: Sat Mar 27 16:28:13 PST 2004.
Request that system choose the sideband.
Base class for Correlator Sideband data.