CARMA C++
SignalPathMapperControlImpl.h
1 #ifndef CARMA_SIGNALPATH_SIGNALPATHCONTROLIMPL_H
2 #define CARMA_SIGNALPATH_SIGNALPATHCONTROLIMPL_H
3 
4 #include "carma/control/CorrDefs.h"
5 
6 #include "carma/monitor/BlockDownconverter.h"
7 #include "carma/monitor/ControlBandCommon.h"
8 #include "carma/monitor/CorrDesignation.h"
10 #include "carma/monitor/SignalPathSubsystem.h"
11 
12 #include "carma/signalpath/SignalPathMapperControl.h"
14 
15 #include "carma/util/PthreadMutex.h"
16 #include "carma/util/SeqTypedefs.h"
17 #include "carma/util/corrUtils.h"
18 
20 #include "carma/szautil/BitMask.h"
21 #include "carma/szautil/PeriodicTimer.h"
22 #include "carma/szautil/String.h"
23 
24 namespace carma {
25  namespace signalpath {
26 
27  class SignalPathMapperControlImpl {
28  public:
29 
30  class SwitchyardConfiguration {
31  public:
32  std::string fileName_;
33  sza::util::String confName_;
34  sza::util::String astroBandConfName_;
36  SignalPathMapperControl::SwitchyardConfiguration tag_;
37 
38  SwitchyardConfiguration(std::string confName,
39  SignalPathMapperControl::SwitchyardConfiguration tag,
40  std::string astroBandConfName,
41  std::string fileName)
42  {
43  confName_ = confName;
44  confName_ = confName_.toUpper();
45 
46  tag_ = tag;
47 
48  astroBandConfName_ = astroBandConfName;
49  astroBandConfName_ = astroBandConfName_.toUpper();
50 
51  fileName_ = fileName;
52  };
53 
54  SwitchyardConfiguration(const SwitchyardConfiguration& conf) {
55  *this = conf;
56  };
57 
58  void operator=(const SwitchyardConfiguration& conf) {
59  *this = (SwitchyardConfiguration&) conf;
60  };
61 
62  void operator=(SwitchyardConfiguration& conf) {
63  fileName_ = conf.fileName_;
64  confName_ = conf.confName_;
65  astroBandConfName_ = conf.astroBandConfName_;
66  tag_ = conf.tag_;
67  };
68 
69  };
70 
71  SignalPathMapperControlImpl();
72 
73  ~SignalPathMapperControlImpl();
74 
75  //-----------------------------------------------------------------------
76  // Begin IDL interface
77  //-----------------------------------------------------------------------
78 
79  // Initialize the hardware (cable) connections from a file
80 
81  void initializeCableMap(std::string fileName);
82 
83  // Load a new configuration from a file
84 
85  void loadConfiguration(std::string fileName, std::string confName, std::string astroBandConfName);
86 
87  // Add an antenna
88 
89  void addAntenna(unsigned short antNo, unsigned short subarrayNo);
90 
91  // Remove an antenna
92 
93  void removeAntenna(unsigned short antNo, unsigned short subarrayNo);
94 
95  // Add a correlator
96 
97  void addCorrelator(carma::util::CorrelatorType type, unsigned short subarrayNo);
98 
99  // Remove a correlator
100 
101  void removeCorrelator(carma::util::CorrelatorType type, unsigned short subarrayNo);
102 
103  // Assert a named configuration for the specified astro band
104 
105  void configureAstroBand(unsigned short bandNo, std::string confName,
106  unsigned short subarrayNo=0,
107  carma::util::CorrelatorType type=carma::util::CORR_ALL);
108 
109  // Check the validity of a configuration
110 
111  void checkConfigurationValidity(unsigned short bandNo, std::string confName,
112  unsigned short subarrayNo=0,
113  carma::util::CorrelatorType type=carma::util::CORR_ALL);
114 
115  // Return the validity of a configuration
116 
117  bool configurationIsValid(unsigned short bandNo, std::string confName,
118  unsigned short subarrayNo=0,
119  carma::util::CorrelatorType type=carma::util::CORR_ALL);
120 
121  // Clear any configuration of the specified astro band
122 
123  void clearAstroBandConfiguration(unsigned short bandNo,
124  unsigned short subarrayNo=0,
125  carma::util::CorrelatorType type=carma::util::CORR_ALL);
126 
127  // Set a walsh column for the named antenna
128 
129  void assignWalshColumn(SignalPathMapperControl::WalshColumnAssignment wca);
130 
131  // Clear a walsh column assignment
132 
133  void clearWalshColumnAssignment(unsigned short antNo);
134 
135  // Get the switch positions for the current configuration
136 
137  carma::switchyard::SwitchPositionSeq*
138  getIFSwitchSettings(unsigned short astroBandNo);
139 
140  carma::switchyard::SwitchPositionSeq*
141  getLOSwitchSettings(unsigned short astroBandNo);
142 
143  carma::switchyard::SwitchPositionSeq*
144  getDCLOSwitchSettings(unsigned short astroBandNo);
145 
146  carma::switchyard::SwitchPositionSeq*
147  getLLSwitchSettings(unsigned short astroBandNo);
148 
149  // Get the FPGA mode of this astro band
150 
152  getFpgaMode(unsigned short astroBandNo);
153 
154  // Get antennas associated with the requested astroband
155 
156  SignalPathMapperControl::AntennaSeq*
157  getAntennas(unsigned short astroBandNo=0);
158 
159  // Get polarizations associated with the requested astroband
160 
161  SignalPathMapperControl::PolarizationSeq*
162  getPolarizations(unsigned short astroBandNo=0);
163 
164  // Get block downconverter settings for the requested astroband
165 
166  SignalPathMapperControl::BlockDownconverterSettingSeq*
167  getBdcSettings(unsigned short astroBandNo=0);
168 
169  // Get the walsh column assignments for all antennas
170 
171  SignalPathMapperControl::WalshColumnAssignmentSeq*
172  getWalshColumnAssignment(unsigned short antNo=0);
173 
174  // Query active correlator bands managed by this correlator
175 
176  SignalPathMapperControl::CorrelatorBandSeq*
177  getActiveCorrelatorBands(carma::util::CorrelatorType type);
178 
179  // Query correlator band input mapping
180 
181  SignalPathMapperControl::CorrelatorBandInputSeq*
182  getCorrelatorBandInputMap(SignalPathMapperControl::CorrelatorBand band);
183 
184  // Query corelator bands associated with this astroband
185 
186  SignalPathMapperControl::CorrelatorBandSeq*
187  getCorrelatorBands(unsigned short astroBandNo);
188 
189  // Get correlator band numbers associated with this astroband
190 
191  carma::util::SeqShort * getCorrelatorBandNoSeq(unsigned short astroBandNo);
192 
193  // Get astro band numbers associated with this correlator
194 
195  carma::util::SeqShort * getActiveAstroBandNoSeq(carma::util::CorrelatorType type);
196 
197  // Query active correlator crates managed by this correlator
198 
199  SignalPathMapperControl::CorrelatorCrateSeq*
200  getActiveCorrelatorCrates(carma::util::CorrelatorType type);
201 
202  // Query active astrobands bands managed by this correlator
203 
204  SignalPathMapperControl::AstroBandSeq*
205  getActiveAstroBands(carma::util::CorrelatorType type);
206 
207  // Query astrobands specified by this configuration
208 
209  SignalPathMapperControl::AstroBandSeq*
210  getAstroBandsForConfiguration(std::string confName,
211  unsigned short subarrayNo,
212  carma::util::CorrelatorType type);
213 
214  // Query correlator crate input mapping
215 
216  SignalPathMapperControl::CorrelatorCrateInputSeq*
217  getCorrelatorCrateInputMap(SignalPathMapperControl::CorrelatorCrate crate);
218 
219  // Returns true if the switch setting does not conflict with any
220  // current Astroband configuration
221 
222  bool canAssertSwitchPosition(carma::switchyard::SwitchPosition pos);
223 
224  // Return the configuration as a printable string
225 
226  char* queryConfiguration();
227 
228  // Check configuration by synchronizing with the monitor stream
229 
230  void checkConfigurationSuccess(unsigned short astroBandNo);
231 
232  // get the switchyard configuration name for the input astroband number
233  char * getConfName(unsigned short astroBandNo );
234 
235  // get the astroband number associated with this correlator band
236  // or -1 if no association.
237 
238  short getAstroBandForCorrelatorBand(unsigned short corrBandNo,
239  carma::util::CorrelatorType type );
240 
241  // Get the correlator type associated with this astroband.
242 
243  carma::util::CorrelatorType getCorrTypeForAstroBand(unsigned short astroBandNo);
244 
245  //-----------------------------------------------------------------------
246  // End IDL interface
247  //-----------------------------------------------------------------------
248 
249  private:
250 
251  // A bitmask of validity for all astrobands
252 
253  sza::util::BitMask invalidMask_;
254 
255  std::vector<int> lastModifiedVec_;
256 
257  sza::util::AbsoluteTimer* writeMonitorSystemTimer_;
258 
259  sza::util::PeriodicTimer* checkConfigTimer_;
260  bool checkConfigEnabled_;
261 
262  std::vector<unsigned> savedAstroBands_;
263  std::vector<CorrelatorBandSpec> savedCorrelatorBands_;
264 
265  std::vector<carma::signalpath::SignalPathMapperControlImpl::SwitchyardConfiguration*> knownConfigurations_;
266 
268 
270  carma::signalpath::SignalPathMap spMapChecker_;
271 
273  carma::monitor::SignalPathSubsystem* msSp_;
275 
276  // Methods to do with the monitor system writer
277 
278  void initializeMonitorSystemWriter();
279  static ABSOLUTE_TIMER_HANDLER(writeMonitorSystemHandler);
280  void writeMonitorSystemWrapper();
281 
282  // Methods to do with the configuration checker
283 
284  void initializeConfigurationChecker();
285  void enableConfigurationChecker(bool enable);
286  static PERIODIC_TIMER_HANDLER(checkConfigHandler);
287 
288  void checkConfigurationSuccessWrapper(unsigned short astroBandNo);
289  void checkConfigurationSuccessLocal(unsigned short astroBandNo, int frameCount);
290 
291  void addCorrelatorLocal(carma::util::CorrelatorType type, unsigned short subarrayNo);
292 
293  void removeCorrelatorLocal(carma::util::CorrelatorType type, unsigned short subarrayNo);
294 
295  // Other methods
296 
297  void markHardwareConfigurationAsValid(unsigned short astroBandNo, bool valid);
298 
299 
300  void clearAstroBandConfigurationLocal(unsigned short bandNo,
301  unsigned short subarrayNo=0,
302  carma::util::CorrelatorType type=carma::util::CORR_ALL);
303 
305  antType(carma::signalpath::AntennaType type);
306 
307  unsigned short
308  switchPos(carma::signalpath::SubarrayId);
309 
310  unsigned short
311  subarrayNumber(carma::signalpath::SubarrayId);
312 
313  carma::signalpath::SubarrayId
314  subarrayId(unsigned short subarrayNo);
315 
316  carma::signalpath::CorrelatorType correlatorType(carma::util::CorrelatorType type);
317 
318  carma::util::CorrelatorType
319  correlatorType(carma::signalpath::CorrelatorType type);
320 
321  MonitorCorrelatorDesignation
322  msCorrelatorType(carma::signalpath::CorrelatorType type);
323 
324  carma::signalpath::SignalPathMapperControl::PolarizationType
325  polType(carma::signalpath::PolarizationType type);
326 
327  carma::monitor::PolarizationMonitorPointEnum::POLARIZATION
328  msPolType(carma::signalpath::PolarizationType type);
329 
330  carma::monitor::BlockDownconverter::PolarizationMonitorPointEnum::POLARIZATION
332 
333  carma::monitor::BlockDownconverter::PolarizationMonitorPointEnum::POLARIZATION
334  msPolType(carma::signalpath::BlockDownconverterInputType type);
335 
336  carma::monitor::SplitterChannelMonitorPointEnum::SPLITTERCHANNEL
337  msSplitterChannel(carma::signalpath::SplitterChannelId channelId);
338 
339  carma::monitor::ConfTagMonitorPointEnum::CONFTAG
340  msConfTag(std::string name);
341 
342  carma::monitor::ConfTagMonitorPointEnum::CONFTAG
343  msConfTag(carma::signalpath::SignalPathMapperControl::SwitchyardConfiguration confTag);
344 
346  astroBandConfToCorrFpgaMode(std::string swConfName, std::string abConfName);
347 
348  carma::monitor::ControlBandPoints::FpgaModeMonitorPointEnum::FPGAMODE
349  msFpgaMode(carma::util::CorrelatorFpgaModeType type);
350 
351  void checkIFSwitchSetting(carma::signalpath::SwitchSetting& swPos);
352  void checkLOSwitchSetting(unsigned short switchNo, unsigned short switchPos);
353  void checkDCLOSwitchSetting(carma::signalpath::SwitchSetting& swPos);
354  void checkLLSwitchSetting(unsigned short switchNo, unsigned short switchPos);
355  void checkBdcSetting(BlockDownconverterSetting& setting);
356  void checkFpgaMode(carma::signalpath::CorrelatorBandSpec& band, carma::util::CorrelatorFpgaModeType spFpgaMode);
357  void checkWalshColumnAssignment(unsigned antNo, unsigned walshColNo);
358 
359  void initialize();
360 
361  void updateMonitorPoints();
362 
363  void updateAstroBandMonitorPoints();
364  void clearAstroBandMonitorPoints();
365 
366  void updateCorrBandMonitorPoints();
367  void clearCorrBandMonitorPoints();
368  void updateCorrBandMonitorPoints(carma::signalpath::CorrelatorType type, bool clear);
369 
370  void updateIFSwitchMonitorPoints();
371  void clearIFSwitchMonitorPoints();
372 
373  void updateAntennaMonitorPoints();
374  void clearAntennaMonitorPoints();
375 
376  void updateSubarrayMonitorPoints();
377  void clearSubarrayMonitorPoints();
378 
379  carma::util::CorrelatorFpgaModeType getFpgaModeLocal(unsigned short astroBandNo);
380 
381  std::vector<carma::signalpath::SwitchSetting>
382  getDCLOSwitchSettingsLocal(unsigned short astroBandNo);
383 
384 
385  void saveCurrentConfiguration(unsigned astroBandNo, carma::util::CorrelatorType type);
386 
387  int getFrameCount();
388  void markSavedConfigurationAsModified(int frameCount);
389 
390  void markAstroBandAsModified(unsigned astroBandNo, int frameCount);
391  void markCorrelatorBandAsModified(CorrelatorBandSpec& band, int frameCount);
392 
393  std::vector<unsigned>
394  getActiveAstroBands(unsigned astroBandNo, carma::util::CorrelatorType type);
395 
396  std::vector<CorrelatorBandSpec>
397  getActiveCorrelatorBands(unsigned astroBandNo, carma::util::CorrelatorType type);
398 
399  }; // class SignalpathControlImpl
400 
401  } // namespace signalpath
402 
403 } // namespace carma
404 
405 #endif
sequence< short > SeqShort
Sequence of CORBA::Short.
Definition: SeqTypedefs.idl:10
Tagged: Tue Mar 6 16:39:02 PST 2012.
CorrelatorFpgaModeType
FPGA configuration modes.
The monitor system base class.
The monitor system for the Control subsystem.
Tagged: Tue Feb 2 14:45:04 NZDT 2010.
Tagged: Wed Nov 24 09:41:29 PST 2010.
A class to encapsulate the switchyard cable map.
CorrelatorType
Enum to encapsulate a correlator type. These.
Definition: SignalPathMap.h:76
AntennaType
Enumeration of possible types for antennas.
Definition: Types.h:210
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
Definition: PthreadMutex.h:41
Tagged: Wed May 12 09:30:13 PDT 2004.