CARMA C++
SignalPathMap.h
Go to the documentation of this file.
1 #ifndef CARMA_SWITCHYARD_SIGNALPATHMAP_H
2 #define CARMA_SWITCHYARD_SIGNALPATHMAP_H
3 
13 //#include "carma/control/CorrDefs.h"
14 
15 #include "carma/util/CorrelatorType.h"
16 #include "carma/szautil/BitMask.h"
17 #include "carma/szautil/String.h"
18 
19 #include <map>
20 #include <utility>
21 #include <string>
22 #include <vector>
23 
24 namespace carma {
25  namespace signalpath {
26 
27  class Antenna;
28  class AntennaIF;
29 
30  class AstroBand;
31  class AstroBandConfiguration;
32  class AstroBandInfo;
33  class AstroBandInput;
34 
35  class Band;
36  class BlockDownconverter;
37  class BlockDownconverterInput;
38 
39  class Correlator;
40 
41  class CorrelatorCrate;
42  class CorrelatorCrateInput;
43 
44  class CorrelatorBand;
45  class CorrelatorBandInput;
46 
47  class SignalPathMap;
48  class Switch;
49  class SwitchChannel;
50 
51  class SwitchyardConfiguration;
52 
53  class WalshColumn;
54 
55  class Digitizer;
56  class FpgaBoard;
57 
58  //------------------------------------------------------------
59  // Enum to encapsulate known configurations
60  //------------------------------------------------------------
61 
62  enum ConfigurationType {
63  CONF_NONE = 0x0,
64  CONF_UNKNOWN = 0x1,
65  CONF_LL = 0x2,
66  CONF_RR = 0x4,
67  CONF_CARMA23 = 0x8,
68  CONF_FULLSTOKES = 0x10,
69  };
70 
71  //------------------------------------------------------------
73  //have the same value as util::CorrelatorType except
74  //CORR_C3G = CORR_C3GMAX8 | CORR_C3GMAX23.
75  //------------------------------------------------------------
77  CORR_NONE = carma::util::CORR_NONE,
78  CORR_SL = carma::util::CORR_SPECTRAL,
79  CORR_WB = carma::util::CORR_WIDEBAND,
80  CORR_C3GMAX8 = carma::util::CORR_C3GMAX8,
81  CORR_C3GMAX23 = carma::util::CORR_C3GMAX23,
82  CORR_C3G = CORR_C3GMAX8 | CORR_C3GMAX23,
83  CORR_ALL = carma::util::CORR_ALL
84  };
85 
86  std::ostream& operator<<(std::ostream& os, const CorrelatorType& type);
87 
88  //------------------------------------------------------------
89  // Enum to encapsulate a block downconverter input type
90  //------------------------------------------------------------
91 
92  enum BlockDownconverterInputType {
93  BD_INP_NONE = 0x0,
94  BD_INP_P1 = 0x1,
95  BD_INP_P2 = 0x2,
96  };
97 
98  std::ostream& operator<<(std::ostream& os, const BlockDownconverterInputType& type);
99 
100  //------------------------------------------------------------
101  // Enum to encapsulate an antenna type
102  //------------------------------------------------------------
103 
104  enum AntennaType {
105  ANT_NONE = 0x0,
106  ANT_SZA = 0x1,
107  ANT_BIMA = 0x2,
108  ANT_OVRO = 0x4,
109  };
110 
111  std::ostream& operator<<(std::ostream& os, const AntennaType& type);
112 
113  //------------------------------------------------------------
114  // Enum to encapsulate a polarization type
115  //------------------------------------------------------------
116 
117  enum PolarizationType {
118  POL_NONE = 0x0,
119  POL_LEFT = 0x1,
120  POL_RIGHT = 0x2,
121  POL_ANY = POL_LEFT | POL_RIGHT
122  };
123 
124  std::ostream& operator<<(std::ostream& os, const PolarizationType& type);
125 
126  //------------------------------------------------------------
127  // Enum to define a splitter channel
128  //------------------------------------------------------------
129 
130  enum SplitterChannelId {
131  SP_CHAN_NONE = 0x0,
132  SP_CHAN_A = 0x1,
133  SP_CHAN_B = 0x2,
134  SP_CHAN_C = 0x4,
135  SP_CHAN_D = 0x8,
136  };
137 
138  std::ostream& operator<<(std::ostream& os, const SplitterChannelId& id);
139 
140  //------------------------------------------------------------
141  // Enum to define a subarray
142  //------------------------------------------------------------
143 
144  enum SubarrayId {
145  SA_NONE = 0x0,
146  SA_1 = 0x1,
147  SA_2 = 0x2,
148  SA_3 = 0x4,
149  SA_4 = 0x8,
150 
151  SA_OFFLINE = SA_NONE,
152  SA_SCI1 = SA_1,
153  SA_SCI2 = SA_2,
154  SA_ENG1 = SA_3,
155  SA_ENG2 = SA_4,
156 
157  SA_ANY = SA_1 | SA_2 | SA_3 | SA_4
158  };
159 
160  //------------------------------------------------------------
161  // Enum to define a switch channel
162  //------------------------------------------------------------
163 
164  enum SwitchChannelId {
165  SW_CHAN_NONE = 0x0,
166  SW_CHAN_1 = 0x1,
167  SW_CHAN_2 = 0x2,
168  SW_CHAN_3 = 0x4,
169  SW_CHAN_4 = 0x8,
170  };
171 
172  std::ostream& operator<<(std::ostream& os, const SwitchChannelId& id);
173 
174  //------------------------------------------------------------
175  // Structs used as return values
176  //------------------------------------------------------------
177 
178  struct AntennaSpec {
179  unsigned antNo_;
180  AntennaType type_;
181  unsigned walshColNo_;
182  SubarrayId subarrayId_; // ID of the subarray currently owning this antenna
183  };
184 
185  struct AntennaIFSpec {
186  unsigned antNo_;
187  PolarizationType polType_;
188  };
189 
190  struct CorrelatorCrateSpec {
191  CorrelatorType type_;
192  unsigned crateNo_;
193  };
194 
195  struct CorrelatorCrateInputSpec {
196  CorrelatorCrateSpec crate_;
197  unsigned inputNo_;
198  AntennaIFSpec antIF_;
199  };
200 
201  struct CorrelatorBandSpec {
202  CorrelatorCrateSpec crate_;
203  unsigned bandNo_;
204  };
205 
206  struct AstroBandInputSpec {
207  unsigned astroBandNo_;
208  unsigned inputNo_;
209  };
210 
211  struct CorrelatorBandInputSpec {
212  CorrelatorBandSpec band_;
213  unsigned inputNo_;
214  AntennaIFSpec antIF_;
215  AstroBandInputSpec astroBandInput_;
216  };
217 
218  //------------------------------------------------------------
221  //------------------------------------------------------------
223  public:
224 
225  virtual void mapFrom( ConnectableNode* caller, CorrelatorType type=CORR_ALL);
226  virtual void clearFrom(ConnectableNode* caller, CorrelatorType type=CORR_ALL);
227  virtual void mapTo( ConnectableNode* caller, CorrelatorType type=CORR_ALL);
228  virtual void clearTo( ConnectableNode* caller, CorrelatorType type=CORR_ALL);
229 
230  ConnectableNode* fromNode_;
231  ConnectableNode* toNode_;
232 
233  ConnectableNode();
234  virtual ~ConnectableNode();
235 
236  friend std::ostream& operator<<(std::ostream& os, const ConnectableNode& node);
237  };
238 
239  //------------------------------------------------------------
243  //------------------------------------------------------------
245  public:
246 
247  // The AstroBand currently controlling this object (NULL if none)
248 
249  unsigned astroBandNo_;
250 
251  virtual bool canBeConfiguredBy(AstroBandInfo* info);
252  virtual bool canBeConfiguredBy(unsigned astroBandNo);
253 
254  // Return the astro band number to which this device is
255  // currently mapped
256 
257  unsigned getCurrentAstroBandNo();
258 
259  // Map an AstroBand to this object
260 
261  virtual void setOwnershipTo(AstroBandInfo* info);
262  virtual void setOwnershipTo(unsigned astroBandNo);
263 
264  virtual void removeFromOwnership(AstroBandInfo* info);
265  virtual void removeFromOwnership(unsigned astroBandNo);
266 
267  virtual bool belongsTo(AstroBandInfo* info);
268  virtual bool isOwnedByNoone();
269  virtual bool requestorMatches(AstroBandInfo* info);
270  virtual bool requestorOwnsAll(AstroBandInfo* info);
271 
276  virtual ~ConfigurableDevice();
277  };
278 
279  //------------------------------------------------------------
282  //------------------------------------------------------------
283 
285  public:
286 
287  // A mask of astro band nos currently controlling this switch
288 
289  sza::util::BitMask astroBandMask_;
290 
291  virtual void setOwnershipTo(AstroBandInfo* info);
292  virtual void setOwnershipTo(unsigned astroBandNo);
293 
294  virtual void removeFromOwnership(AstroBandInfo* info);
295  virtual void removeFromOwnership(unsigned astroBandNo);
296 
297  virtual bool isOwnedByNoone();
298 
299  virtual bool isSoleOwner(AstroBandInfo* info);
300  virtual bool isSoleOwner(unsigned astroBandNo);
301 
302  virtual bool belongsTo(AstroBandInfo* info);
303  virtual bool belongsTo(unsigned astroBandNo);
304 
305  virtual bool requestorMatches(AstroBandInfo* info);
306  virtual bool requestorMatches(unsigned astroBandNo);
307 
308  virtual bool requestorOwnsAll(AstroBandInfo* info);
309  virtual bool requestorOwnsAll(unsigned astroBandNo);
310 
311  virtual bool canBeConfiguredBy(AstroBandInfo* info);
312  virtual bool canBeConfiguredBy(unsigned astroBandNo);
313 
314  std::string listOwners();
315  };
316 
317  //------------------------------------------------------------
318  // Class to encapsulate a single copy of an antenna IF
319  //------------------------------------------------------------
320 
321  class AntennaIF : public ConnectableNode {
322  public:
323 
324  // The parent antenna of this IF
325 
326  Antenna* antenna_;
327 
328  // The polarization type of this IF
329 
330  PolarizationType polType_;
331 
332  // The splitter channel of this IF (SP_CHAN_NONE if none)
333 
334  SplitterChannelId splitterChannel_;
335 
336  // Constructor for an antenna IF
337 
338  AntennaIF(Antenna* antenna, PolarizationType polType, SplitterChannelId splitterChannel);
339  virtual ~AntennaIF();
340 
341  void validateAntenna();
342  Antenna* getAntenna();
343 
344  // Return true if this IF is selected by the current switch settings
345 
346  bool isUsedByConfiguredAstroBand();
347 
348  // Print operators
349 
350  std::string printDown();
351  std::string printUp();
352 
353  friend std::ostream& operator<<(std::ostream& os, const AntennaIF& antIf);
354  };
355 
356  //------------------------------------------------------------
357  // An object to encapsulate the switch channel to which an
358  // antenna IF is connected
359  //------------------------------------------------------------
360 
361  class SwitchChannel : public ConnectableNode {
362  public:
363 
364  // Pointer to the switch to which this channel belongs
365 
366  Switch* switch_;
367 
368  // The channel id of this channel
369 
370  SwitchChannelId channelId_;
371 
372  // A pointer to the antenna IF connected to this switch channel (NULL if none)
373 
374  AntennaIF* if_;
375 
376  // Constructor
377 
378  SwitchChannel(Switch* sw, SwitchChannelId channelId);
379  virtual ~SwitchChannel();
380 
381  void validateAntennaIF();
382  AntennaIF* getAntennaIF();
383 
384  // Print operators
385 
386  std::string printDown();
387  std::string printUp();
388 
389  friend std::ostream& operator<<(std::ostream& os, const SwitchChannel& swChan);
390  };
391 
392  //------------------------------------------------------------
393  // A class to encapsulate a single switch
394  //
395  // Class maintains a map of Antenna Polarizations connected to
396  // each of its inputs
397  //
398  // Switch is a configurable device, since its state can be changed
399  // to select an input
400  //------------------------------------------------------------
401 
402  class Switch : public ConfigurableDeviceMultiAstroBand, public ConnectableNode {
403  public:
404 
405  // The carma-style index of this switch (switch number, 1-38)
406 
407  unsigned switchNo_;
408 
409  // The name of this switch (in the convention of DW's memo)
410 
411  std::string name_;
412 
413  // A map of valid channels for this switch
414 
415  std::map<SwitchChannelId, SwitchChannel*> channelMap_;
416 
417  // The currently selected switch channel
418 
419  SwitchChannel* currentChannel_;
420 
421  // The blockdownconverter input that this switch is connected to
422 
423  BlockDownconverterInput* bdcInput_;
424 
425  // Constructor for Switch
426 
427  Switch(unsigned id, std::string name);
428  Switch(const Switch& sw);
429  Switch(Switch& sw);
430 
431  // Assignment operators
432 
433  void operator=(const Switch& sw);
434  void operator=(Switch& sw);
435 
436  void initialize(unsigned id, std::string name);
437  void initializeChannelMap();
438  void clearChannelMap();
439  void clearSwitchSetting();
440  bool isUsedByConfiguredAstroBand();
441 
442  void validateBdcInput();
443  BlockDownconverterInput* getBdcInput();
444 
445  void validateCurrentChannel();
446  SwitchChannel* getCurrentChannel();
447 
448  // Validate the specified channel selection for this switch
449 
450  void validateChannel(SwitchChannelId chanId);
451 
452  // Set this switch to the specified channel
453 
454  void selectChannel(SwitchChannelId chanId);
455 
456  bool canBeConfiguredBy(AstroBandInfo* info, SwitchChannel* channel);
457 
458  virtual ~Switch();
459 
460  // Print operators
461 
462  std::string printDown();
463 
464  friend std::ostream& operator<<(std::ostream& os, const Switch& sw);
465  };
466 
467  //------------------------------------------------------------
468  // A class to encapsulate a walsh function
469  //------------------------------------------------------------
470 
471  class WalshColumn {
472  public:
473 
474  unsigned walshColNo_;
475  bool hardwired_;
476 
477  // The map of walsh column assignments that would be assigned by
478  // each subarray
479 
480  std::map<CorrelatorType, unsigned> corrWalshColMap_;
481 
482  static const unsigned nWalshCol_;
483 
484  WalshColumn();
485 
486  void clear();
487  void validateWalshColNo(unsigned walshColNo);
488  void setWalshColNo(unsigned walshColNo, bool override=false);
489  unsigned getWalshColNo();
490  void setHardwired(bool hardwired);
491  bool isHardwired();
492  bool isSet();
493 
494  // Virtual walsh columns -- stores information about the walsh
495  // column that would be set by a subarray (in the case of an
496  // antenna, if that subarray owned the corresponding antenna)
497 
498  void setWalshColNo(unsigned walshColNo, CorrelatorType type);
499  unsigned getWalshColNo(CorrelatorType type);
500  bool isSet(CorrelatorType type);
501 
502  bool operator==(WalshColumn& wf);
503  bool operator!=(WalshColumn& wf);
504  void operator=(WalshColumn& wf);
505 
506  friend std::ostream& operator<<(std::ostream& os, const WalshColumn& wc);
507  };
508 
509  //------------------------------------------------------------
511  //------------------------------------------------------------
512  class Correlator {
513  public:
514 
515  Correlator(CorrelatorType type, SubarrayId subarrayId_);
516  virtual ~Correlator();
517 
518  bool requestToRelease(SubarrayId subarrayId_);
519  void requestToControl(SubarrayId subarrayId_);
520 
521  CorrelatorType type_;
522  SubarrayId subarrayId_;
523 
524  std::vector<Correlator*> exclusiveCorrelators_;
525  };
526 
527  //------------------------------------------------------------
529  //------------------------------------------------------------
530 
532  public:
533 
534  // The type of this correlator crate
535 
536  CorrelatorType type_;
537 
538  // The unqualified name of this correlator
539 
540  std::string name_;
541 
542  // The qualified number of this correlator (interpretation
543  // depends on type)
544 
545  unsigned crateNo_;
546 
547  // A vector of correlator inputs for this crate
548 
549  std::vector<CorrelatorCrateInput*> inputs_;
550 
551  CorrelatorCrate(CorrelatorType type, unsigned crateNo);
552 
553  virtual ~CorrelatorCrate();
554 
555  CorrelatorCrateInput* getInput(unsigned inputNo);
556  void validateInput(unsigned inputNo);
557 
558  static const unsigned nInput_;
559  static const unsigned nCrateSl_;
560  static const unsigned nCrateWb_;
561  static const unsigned nInputPerBandWb_;
562  static const unsigned nInputPerBandSl_;
563  };
564 
565  //------------------------------------------------------------
566  // Class to encapsulate a single correlator input
567  //
568  // A correlator input is not technically configurable, since it is
569  // hardwired to a block downconverter band, but it inherits the
570  // configurable interface, since it is connected to a configurable
571  // device
572  //------------------------------------------------------------
573 
574  class CorrelatorCrateInput : public ConfigurableDevice, public ConnectableNode {
575  public:
576 
577  // The CARMA-style number of this crate input
578 
579  unsigned inputNo_;
580 
581  // The crate to which this input belongs
582 
583  CorrelatorCrate* crate_;
584 
585  // The walsh function associated with this input
586 
587  WalshColumn walshCol_;
588 
589  // The block downconverter band connected to this input (NULL if
590  // none)
591 
592  Band* bdcBand_;
593 
594  // The correlator band input to which this crate input is
595  // currently mapped
596 
597  CorrelatorBandInput* corrBandInput_;
598 
599  void clear(CorrelatorType type=CORR_ALL);
600 
601  // Validate the block downconverter band to which this input is
602  // connected
603 
604  Band* getBdcBand();
605  void validateBdcBand();
606 
607  // Validate the correlator band input associated with this correlator crate
608 
609  CorrelatorBandInput* getCorrelatorBandInput();
610  void validateCorrelatorBandInput();
611 
612  // Validate the astro band input associated with this correlator crate
613 
614  AstroBandInput* getAstroBandInput();
615  void validateAstroBandInput();
616  bool isConnectedToAstroBand();
617 
618  void mapTo(CorrelatorBandInput* input);
619 
620  CorrelatorCrateInput(CorrelatorCrate* parent, unsigned inputNo);
621  ~CorrelatorCrateInput();
622 
623  bool isUsedByConfiguredAstroBand();
624 
625  // Inherited part of the ConnectableNode interface
626 
627  void mapTo( ConnectableNode* input, CorrelatorType type=CORR_ALL);
628  void clearTo(ConnectableNode* input, CorrelatorType type=CORR_ALL);
629  };
630 
631  //------------------------------------------------------------
632  // Class to encapsulate a single band.
633  //
634  // Block downconverter bands are configurable, since the P1/P2
635  // input can be chosen
636  //------------------------------------------------------------
637 
638  class Band : public ConfigurableDevice {
639  public:
640 
641  // The carma-style index of this band
642 
643  unsigned bandNo_;
644 
645  // The parent block downconverter of this band
646 
647  BlockDownconverter* bdc_;
648 
649  // The correlator input this band is connected to (NULL if none)
650 
651  CorrelatorCrateInput* corrInput_;
652 
653  // The currently selected block downconverter input for this
654  // band (NULL if none)
655 
656  BlockDownconverterInput* bdcInput_;
657 
658  Band(BlockDownconverter* parent, unsigned bandNo);
659 
660  void clear();
661 
662  void mapBdcInput(BlockDownconverterInput* input);
663 
664  bool isUsedByConfiguredAstroBand();
665  bool isSelected();
666 
667  std::string printUp();
668 
669  // Accessor methods
670 
671  void validateBdc();
672  BlockDownconverter* getBdc();
673 
674  void validateBdcInput();
675  BlockDownconverterInput* getBdcInput();
676 
677  void validateCorrelatorCrateInput();
678  CorrelatorCrateInput* getCorrelatorCrateInput();
679  };
680 
681  //------------------------------------------------------------
682  // Class to encapsulate a single correlator input
683  //------------------------------------------------------------
684 
685  class BlockDownconverterInput {
686  public:
687 
688  // The parent downconverter of this input
689 
690  BlockDownconverter* bdc_;
691 
692  // The type of this input
693 
694  BlockDownconverterInputType type_;
695 
696  // A pointer to the switch connected to this bd input.
697  // (NULL if none)
698 
699  Switch* switch_;
700 
701  // A vector of bands to which this input is currently connected
702  // (size 0 if none)
703 
704  std::vector<Band*> bands_;
705 
706  // Constructor for a BlockDownconverter input
707 
708  BlockDownconverterInput(BlockDownconverter* bdc, BlockDownconverterInputType type);
709 
710  // Clear hardware mappings for this class
711 
712  void clear();
713 
714  // Add a band to this object's list of bands
715 
716  void addBand(Band* band);
717 
718  // Remove a band from this object's list of bands
719 
720  void removeBand(Band* band);
721 
722  void validateSwitch();
723  Switch* getSwitch();
724 
725  void validateBdc();
726  BlockDownconverter* getBdc();
727 
728  bool isUsedByConfiguredAstroBand();
729 
730  // Print operators
731 
732  std::string printDown(std::ostringstream& ios, bool printBands);
733  std::string printUp();
734 
735  friend std::ostream& operator<<(std::ostream& os, const BlockDownconverterInput& bdcInput);
736  };
737 
738  //------------------------------------------------------------
739  // Class to encapsulate a single block downconverter
740  //------------------------------------------------------------
741 
742  class BlockDownconverter {
743  public:
744 
745  // The number of bands per correlator type
746 
747  static const unsigned nBandSl_;
748  static const unsigned nBandWb_;
749  static const unsigned nBandC3g_;
750 
751  // A carma-style index for this block downconverter
752 
753  unsigned bdcNo_;
754 
755  // The type of this block downconverter
756 
757  CorrelatorType type_;
758 
759  // A map of valid inputs for this block downconverter
760 
761  std::map<BlockDownconverterInputType, BlockDownconverterInput*> inputMap_;
762 
763  // A vector of bands for this downconverter
764 
765  std::vector<Band*> bands_;
766 
767  // Constructor
768 
769  BlockDownconverter(unsigned bdcIndex, CorrelatorType type);
770  BlockDownconverter(const BlockDownconverter& ant);
771  BlockDownconverter(BlockDownconverter& ant);
772 
773  // Destructor
774 
775  virtual ~BlockDownconverter();
776 
777  // Assignment operators
778 
779  void operator=(const BlockDownconverter& ant);
780  void operator=(BlockDownconverter& ant);
781 
782  void initialize(unsigned bdcIndex, CorrelatorType type);
783  void initializeInputMap(CorrelatorType type);
784  void initializeBands(CorrelatorType type);
785  void clear();
786 
787  BlockDownconverterInput* getInput(BlockDownconverterInputType type);
788  void validateInput(BlockDownconverterInputType type);
789 
790  unsigned nBand();
791 
792  static unsigned nBand(CorrelatorType type);
793 
794  Band* getBand(unsigned bandNo);
795  void validateBand(unsigned bandNo);
796 
797  std::string printUp();
798 
799  std::string printBandVec(std::vector<Band*>& bands);
800 
801  friend std::ostream& operator<<(std::ostream& os, const BlockDownconverter& corr);
802  };
803 
804  //------------------------------------------------------------
805  // Class to encapsulate a single "correlator band"
806  //------------------------------------------------------------
807 
808  class CorrelatorBand : public ConnectableNode {
809  public:
810 
811  // The maximum number of bands
812 
813  static const unsigned nBandMax_;
814 
815  // The number of inputs per correlator type
816 
817  static const unsigned nInputSl_;
818  static const unsigned nInputWb_;
819  static const unsigned nInputC3g_;
820 
821  // The parent crate of this correlator band
822 
823  CorrelatorCrate* crate_;
824  CorrelatorType type_;
825 
826  // Convenience temp variable
827 
828  CorrelatorType tmpType_;
829 
830  // The band number
831 
832  unsigned bandNo_;
833 
834  // The band name
835 
836  std::string name_;
837 
838  // The vector of inputs associated with this correlator band
839 
840  std::vector<CorrelatorBandInput*> inputs_;
841 
842  CorrelatorBand(CorrelatorCrate* crate, unsigned bandNo);
843  CorrelatorBand(CorrelatorType type, unsigned bandNo);
844 
845  virtual ~CorrelatorBand();
846 
847  void initializeInputMap();
848 
849  CorrelatorBandInput* getInput(unsigned inputNo);
850  void validateInput(unsigned inputNo);
851  };
852 
853  //------------------------------------------------------------
854  // Class to encapsulate a single "correlator band" input
855  //------------------------------------------------------------
856 
857  class CorrelatorBandInput : public ConfigurableDevice, public ConnectableNode {
858  public:
859 
860  // The band to which we belong
861 
862  CorrelatorBand* band_;
863 
864  // The correlator crate input to which we are mapped
865 
866  CorrelatorCrateInput* crateInput_;
867 
868  // The band input number
869 
870  unsigned inputNo_;
871 
872  // The Walsh column associated with this input
873 
874  WalshColumn walshCol_;
875 
876  CorrelatorBandInput(CorrelatorBand* band, unsigned inputNo);
877 
878  virtual ~CorrelatorBandInput();
879 
880  void mapTo(CorrelatorCrateInput* input);
881 
882  CorrelatorCrateInput* getCrateInput();
883  void validateCrateInput();
884  bool isConnectedToCrate();
885 
886  // Return the antenna IF this band input is associated with (if
887  // any)
888 
889  AntennaIF* getAntennaIF();
890 
891  // Validate the astro band input associated with this correlator
892  // band (if any)
893 
894  AstroBandInput* getAstroBandInput();
895  void validateAstroBandInput();
896  bool isConnectedToAstroBand();
897 
898  // Overload of ConnectableNode interface
899 
900  void clearTo(ConnectableNode* node, CorrelatorType type);
901  void mapTo(ConnectableNode* node, CorrelatorType type);
902 
903  // Overload of ConfigurableDevice interface
904 
905  bool canBeConfiguredBy(AstroBandInfo* info);
906  void setOwnershipTo(AstroBandInfo* info);
907  void removeFromOwnership(unsigned astroBandNo);
908 
909  friend std::ostream& operator<<(std::ostream& os, const CorrelatorBandInput& input);
910  };
911 
912  //------------------------------------------------------------
913  // Class to encapsulate a single "Astronomical band"
914  //------------------------------------------------------------
915 
916  class AstroBand {
917  public:
918 
919  // The current switchyard configuration
920 
921  SwitchyardConfiguration* conf_;
922 
923  // The maximum number of bands
924 
925  static const unsigned nBandMax_;
926 
927  // The maximum number of inputs per astro band
928 
929  static const unsigned nInputMax_;
930 
931  // The band number
932 
933  unsigned bandNo_;
934 
935  // For use with the new correlator, we add a type check to
936  // astrobands themselves (as opposed to the previous incarnation
937  // of the SPM, which only checked the type of the hardware to
938  // which astrobands were connected. This is because we are now
939  // making conceptual distinctions between 'subarrays' of the new
940  // correlator, which trace back to the same hardware, but
941  // which we nonetheless want mutually exclusive control of)
942 
943  CorrelatorType type_;
944 
945  // The vector of inputs associated with this astro band
946 
947  std::vector<AstroBandInput*> inputs_;
948 
949  // True if this band has previously been configured
950 
951  bool isConfigured_;
952 
953  // Which subarray last configured this astroband?
954 
955  SubarrayId subarrayId_;
956 
957  // Clear any configuration of this band
958 
959  void clear(CorrelatorType type=CORR_ALL, SubarrayId saId=SA_NONE);
960 
961  AstroBandInput* getInput(unsigned inputNo);
962  void validateInput(unsigned inputNo);
963 
964  SwitchyardConfiguration* getSwitchyardConfiguration();
965  void validateSwitchyardConfiguration();
966 
967  AstroBand(unsigned bandNo_);
968  AstroBand(const AstroBand& band);
969  AstroBand(AstroBand& band);
970 
971  virtual ~AstroBand();
972 
973  // Assignment operators
974 
975  void operator=(const AstroBand& band);
976  void operator=(AstroBand& band);
977 
978  void initialize(unsigned bandNo);
979  void initializeInputMap();
980 
981  void addBoard(FpgaBoard* part);
982 
983  // Get a vector of astrobands associated with the requested
984  // correlator
985 
986  static std::vector<unsigned> getAstroBandNos(CorrelatorType type);
987  };
988 
989  class AstroBandInfo {
990  public:
991  AstroBandConfiguration* astroBandConf_;
992  unsigned astroBandNo_;
993  bool conflicted_;
994  unsigned nDevicesConfigured_;
995 
996  sza::util::BitMask conflictMask_;
997 
998  unsigned antConflictMask_;
999  unsigned conflictedSubarrayId_;
1000  SubarrayId subarrayId_;
1001 
1002  // If true, check for devices that this band is currently allowed to configure.
1003  // If false, check only for what is possible
1004 
1005  bool checkCurrentlyAllowed_;
1006 
1007  AstroBandInfo(unsigned astroBandNo, SubarrayId saId=SA_ANY);
1008 
1009  void reset();
1010 
1011  static void incrementConfiguredDevices(AstroBandInfo* info);
1012  static void registerConflict(AstroBandInfo* info, Switch* sw);
1013  static void registerConflict(AstroBandInfo* info, Digitizer* dig);
1014  static void registerConflict(AstroBandInfo* info, CorrelatorCrateInput* input);
1015  static void registerConflict(AstroBandInfo* info, CorrelatorBandInput* input);
1016  static void registerConflict(AstroBandInfo* info, Antenna* ant);
1017  static void registerConflict(AstroBandInfo* info, FpgaBoard* part);
1018 
1019  static bool isOk(AstroBandInfo* info);
1020  static bool isConflicted(AstroBandInfo* info);
1021  static std::string listConflictedBands(AstroBandInfo* info);
1022  static std::string listConflictedAntennas(AstroBandInfo* info);
1023 
1024  friend std::ostream& operator<<(std::ostream& os, const AstroBandInfo& info);
1025  };
1026 
1027  std::ostream& operator<<(std::ostream& os, const AstroBandInfo& info);
1028 
1029  //------------------------------------------------------------
1030  // Class to encapsulate a single "Astronomical band" input
1031  //------------------------------------------------------------
1032 
1033  class AstroBandInput : public ConnectableNode {
1034  public:
1035 
1036  // The band to which this input belongs
1037 
1038  AstroBand* band_;
1039 
1040  // The input number
1041 
1042  unsigned inputNo_;
1043 
1044  // True if this input is required by the currently specified
1045  // configuration for an astroband. (Note that an astroband <-->
1046  // correlator mapping may specify inputs that are not required
1047  // by a configuration. For example, the dual crate
1048  // configuration maps astroband inputs 1-32 to up to 32
1049  // correlator crate inputs, but carma23 only uses 23 of those
1050  // inputs, and fullstokes will use only 30 of those inputs).
1051  //
1052  // This flag will indicate if this astroband input is configured
1053  // by the current configuration
1054 
1055  bool isConfigured_;
1056 
1057  CorrelatorCrateInput* getCrateInput();
1058  void validateCrateInput();
1059  bool isConnectedToCrate();
1060  void clearCrateInput(CorrelatorType type, AstroBandInfo& info);
1061 
1062  CorrelatorBandInput* getBandInput();
1063  void validateBandInput();
1064  bool isConnectedToBand();
1065  void clearBandInput(CorrelatorType type, AstroBandInfo& info);
1066 
1067  AntennaIF* getAntennaIF();
1068 
1069  AstroBandInput(AstroBand* parent, unsigned inputNo_);
1070  virtual ~AstroBandInput();
1071 
1072  bool isUsedByConfiguredAstroBand();
1073 
1074  // Inherited part of the ConnectableNode interface
1075 
1076  void mapFrom( ConnectableNode* node, CorrelatorType type=CORR_ALL);
1077  void clearFrom(ConnectableNode* node, CorrelatorType type=CORR_ALL);
1078 
1079  friend std::ostream& operator<<(std::ostream& os, const AstroBandInput& input);
1080  };
1081 
1082  //------------------------------------------------------------
1083  // Class to encapsulate a single antenna
1084  //------------------------------------------------------------
1085 
1086  class Antenna : public ConfigurableDevice {
1087  public:
1088 
1089  // The type of this antenna
1090 
1091  AntennaType type_;
1092 
1093  // The carma-style index of this antenna (1-23)
1094 
1095  unsigned antNo_;
1096 
1097  // The current walsh-function for this antenna
1098 
1099  WalshColumn walshCol_;
1100 
1101  // The subarray currently owning this antenna
1102 
1103  SubarrayId subarrayId_;
1104 
1105  // A map of valid IFs for this antenna
1106 
1107  std::map<SplitterChannelId, AntennaIF*> ifMap_;
1108 
1109  // A mask of astro band nos currently attached to this antenna
1110 
1111  sza::util::BitMask astroBandMask_;
1112 
1113  // Constructors for antenna
1114 
1115  Antenna(unsigned carmaId, AntennaType type);
1116  Antenna(const Antenna& ant);
1117  Antenna(Antenna& ant);
1118 
1119  // Assignment operators
1120 
1121  void operator=(const Antenna& ant);
1122  void operator=(Antenna& ant);
1123 
1124  void initialize(unsigned carmaId, AntennaType type);
1125  void initializeIfMap(AntennaType type);
1126  void clearIfMap();
1127 
1128  virtual ~Antenna();
1129 
1130  bool canBeConfiguredBy(AstroBandInfo* info);
1131  void setOwnershipTo(AstroBandInfo* info);
1132  void removeFromOwnership(AstroBandInfo* info);
1133 
1134  // Print operators
1135 
1136  std::string printDown();
1137 
1138  friend std::ostream& operator<<(std::ostream& os, const Antenna& ant);
1139  };
1140 
1141  //------------------------------------------------------------
1142  // A class to encapsulate a single switch setting
1143  //------------------------------------------------------------
1144 
1145  class SwitchSetting {
1146  public:
1147  unsigned switchNo_;
1148  SwitchChannelId channel_;
1149  };
1150 
1151  //------------------------------------------------------------
1152  // A class to encapsulate a single block downconverter setting
1153  //------------------------------------------------------------
1154 
1155  class BlockDownconverterSetting {
1156  public:
1157  unsigned bdcNo_;
1158  unsigned bandNo_;
1159  BlockDownconverterInputType input_;
1160  };
1161 
1162  //------------------------------------------------------------
1163  // Walsh column assignment
1164  //------------------------------------------------------------
1165 
1166  class WalshColumnAssignment {
1167  public:
1168  unsigned antNo_;
1169  unsigned walshColNo_;
1170  };
1171 
1172  //------------------------------------------------------------
1173  // A class to encapsulate a single FPGA partition
1174  //------------------------------------------------------------
1175 
1176  class FpgaBoard : public ConfigurableDeviceMultiAstroBand, public ConnectableNode {
1177  public:
1178 
1179  FpgaBoard(SignalPathMap* spm, unsigned inputNo, std::string name, CorrelatorType type);
1180  virtual ~FpgaBoard();
1181 
1182  // The type of the correlator to which this board belongs
1183 
1184  CorrelatorType type_;
1185 
1186  // The name of this board
1187 
1188  std::string name_;
1189 
1190  // A vector of CorrelatorBandInputs this board is connected to
1191 
1192  std::vector<CorrelatorBandInput*> corrBandInputs_;
1193 
1194  // An FPGA board has an astroband configuration associated with
1195  // it
1196 
1197  AstroBandConfiguration* astroBandConf_;
1198 
1199  // Overload of ConfigurableDevice interface
1200 
1201  bool canBeConfiguredBy(AstroBandInfo* info);
1202  void setOwnershipTo(AstroBandInfo* info);
1203  void removeFromOwnership(unsigned astroBandNo);
1204 
1205  friend std::ostream& operator<<(std::ostream& os, const FpgaBoard& brd);
1206  };
1207 
1208  //------------------------------------------------------------
1209  // A class to encapsulate a single component of an AstroBand
1210  // configuration
1211  //------------------------------------------------------------
1212 
1213  class AstroBandInputMapping {
1214  public:
1215 
1216  std::string astroSpec_; // The astro-band specification
1217  std::string inputSpec_; // The correlator/bdc input specification
1218 
1219  AstroBandInputMapping(std::string spec1, std::string spec2);
1220  AstroBandInputMapping(const AstroBandInputMapping& conf);
1221  AstroBandInputMapping(AstroBandInputMapping& conf);
1222 
1223  void operator=(const AstroBandInputMapping& conf);
1224  void operator=(AstroBandInputMapping& conf);
1225 
1226  virtual ~AstroBandInputMapping();
1227  };
1228 
1229  //------------------------------------------------------------
1230  // Class to encapsulate a single FPGA configuration
1231  //------------------------------------------------------------
1232 
1233  class AstroBandConfiguration {
1234  public:
1235 
1236  std::string name_; // A handle for this configuration
1237 
1238  // The vector of mappings corresponding to this configuration
1239 
1240  std::vector<AstroBandInputMapping> inputMappings_;
1241 
1242  AstroBandConfiguration();
1243  AstroBandConfiguration(const AstroBandConfiguration& conf);
1244  AstroBandConfiguration(AstroBandConfiguration& conf);
1245 
1246  void operator=(const AstroBandConfiguration& conf);
1247  void operator=(AstroBandConfiguration& conf);
1248 
1249  virtual ~AstroBandConfiguration();
1250  };
1251 
1252  //------------------------------------------------------------
1253  // A class to encapsulate a single component of a Switchyard
1254  // configuration
1255  //------------------------------------------------------------
1256 
1257  class AntennaIFMapping {
1258  public:
1259 
1260  std::string ifSpec_; // The IF specification
1261  std::string inputSpec_; // The correlator/bdc input specification
1262 
1263  AntennaIFMapping(std::string ifSpec, std::string inputSpec);
1264  AntennaIFMapping(const AntennaIFMapping& conf);
1265  AntennaIFMapping(AntennaIFMapping& conf);
1266 
1267  void operator=(const AntennaIFMapping& conf);
1268  void operator=(AntennaIFMapping& conf);
1269 
1270  virtual ~AntennaIFMapping();
1271  };
1272 
1273  //------------------------------------------------------------
1274  // A class to encapsulate a single Switchyard configuration
1275  //------------------------------------------------------------
1276 
1277  class SwitchyardConfiguration {
1278  public:
1279 
1280  // The name of this configuration
1281 
1282  std::string name_;
1283 
1284  // The vector of mappings corresponding to this configuration
1285 
1286  std::vector<AntennaIFMapping> ifMappings_;
1287 
1288  // The AstroBand mapping associated with this configuration
1289 
1290  AstroBandConfiguration* astroBandConf_;
1291 
1292  AstroBandConfiguration* getAstroBandConfiguration();
1293  void validateAstroBandConfiguration();
1294 
1295  SwitchyardConfiguration();
1296  SwitchyardConfiguration(const SwitchyardConfiguration& conf);
1297  SwitchyardConfiguration(SwitchyardConfiguration& conf);
1298 
1299  void operator=(const SwitchyardConfiguration& conf);
1300  void operator=(SwitchyardConfiguration& conf);
1301 
1302  virtual ~SwitchyardConfiguration();
1303  };
1304 
1305  //------------------------------------------------------------
1306  // A class to encapsulate digitizers of the new correlator
1307  //------------------------------------------------------------
1308 
1309  class Digitizer : public ConfigurableDeviceMultiAstroBand, public ConnectableNode {
1310  public:
1311 
1312  // The correlator to which this digitizer belongs
1313 
1314  CorrelatorType type_;
1315 
1316  // The unqualified name of this digitizer
1317 
1318  std::string name_;
1319 
1320  // The CARMA-style number of this digitizer
1321 
1322  unsigned digitizerNo_;
1323 
1324  // The astroband inputs to which this digitizer is currently
1325  // connected
1326 
1327  std::vector<AstroBandInput*> astroBandInputs_;
1328 
1329  // The bandformer boards to which this digitizer is connected
1330 
1331  std::vector<FpgaBoard*> bandFormers_;
1332 
1333  bool isUsedByConfiguredAstroBand();
1334 
1335  std::string printDown();
1336 
1337  Digitizer(SignalPathMap* spm, CorrelatorType type, unsigned digitizerNo);
1338  ~Digitizer();
1339 
1340  // Get any antenna IF this digitizer may be connected to
1341 
1342  AntennaIF* getAntennaIF();
1343 
1344  // Inherited part of the ConnectableNode interface
1345 
1346  void mapTo(ConnectableNode* toNode, CorrelatorType type=CORR_ALL);
1347  void clearTo(ConnectableNode* toNode, CorrelatorType type=CORR_ALL);
1348  void mapFrom(ConnectableNode* fromNode, CorrelatorType type=CORR_ALL);
1349 
1350  // Inherited part of ConfigurableDevice interface
1351 
1352  bool canBeConfiguredBy(AstroBandInfo* info);
1353 
1354  friend std::ostream& operator<<(std::ostream& os, const Digitizer& dig);
1355  };
1356 
1357  //------------------------------------------------------------
1359  //------------------------------------------------------------
1360 
1362  public:
1363 
1364  // Constants used by this class
1365 
1366  static const unsigned nSza_;
1367  static const unsigned nBima_;
1368  static const unsigned nOvro_;
1369  static const unsigned nAnt_;
1370 
1371  static const unsigned nSubarray_;
1372 
1373  static const unsigned nSl_;
1374  static const unsigned nWb_;
1375 
1376  static const unsigned nSwitch_;
1377  static const unsigned nBdc_;
1378 
1379  static const unsigned nDigitizer_;
1380 
1381  // Constructor.
1382 
1383  SignalPathMap();
1384 
1385  // Destructor.
1386 
1387  virtual ~SignalPathMap();
1388 
1389  // Initialize the hardware (cable) connections from a file
1390 
1391  void initializeCableMap(std::string fileName);
1392 
1393  // Assert a named configuration for the specified astro band
1394 
1395  void configureAstroBand(unsigned bandNo, std::string confName,
1396  SubarrayId saId=SA_NONE, CorrelatorType type=CORR_ALL);
1397 
1398  // These methods will be used to tell the signalpath mapper
1399  // which antennas are actually in a subarray at any given time.
1400  //
1401  // This in turn will be used to determine:
1402  //
1403  // 1) valid walsh columns for an antenna
1404  //
1405  // 2) LO and LL switchyard settings for an antenna
1406 
1407  void addAntenna(unsigned antNo, SubarrayId subarrayId);
1408  void removeAntenna(unsigned antNo, SubarrayId subarrayId);
1409 
1410  // These methods will be used to tell the signalpath mapper
1411  // which correlators are controlled by which subarrays
1412 
1413  void addCorrelator(CorrelatorType type, SubarrayId subarrayId);
1414 
1415  // Returns true if this call actually resulted in a change of
1416  // ownership of the requested correlator
1417 
1418  bool removeCorrelator(CorrelatorType type, SubarrayId subarrayId);
1419 
1420  //------------------------------------------------------------
1421  // Test whether we can assert a named configuration for the
1422  // specified astro band.
1423  //------------------------------------------------------------
1424 
1425  // This method throws, with an informative error
1426 
1427  void checkAstroBandConfiguration(unsigned bandNo, std::string confName,
1428  SubarrayId saId=SA_NONE, CorrelatorType type=CORR_ALL);
1429 
1430  // This method quietly returns a boolean
1431 
1432  bool astroBandConfigurationIsValid(unsigned bandNo, std::string confName,
1433  SubarrayId saId=SA_NONE, CorrelatorType type=CORR_ALL);
1434 
1435  // Return a boolean if the configuration specifies a mapping for the specified bandNo
1436 
1437  bool astroBandConfigurationSpecifiesMapping(unsigned bandNo, std::string confName, SubarrayId saId, CorrelatorType type);
1438 
1439  // Map one or omore correlator inputs to astro band inputs
1440 
1441  void mapCorrToAstroBand(std::string corrSpec, std::string astroSpec,
1442  bool doMapping=true, unsigned baseIndex=0, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1443 
1444  // Map a set of digitizers to astro band inputs
1445 
1446  void mapDigitizerToAstroBand(std::string digSpec, std::string astroSpec,
1447  bool doMapping=true, unsigned baseIndex=0, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1448 
1449 
1450  // Map a set of correlator band inputs to a set of astroband
1451  // inputs
1452 
1453  void mapBandToAstroBand(std::string bandSpec, std::string astroSpec,
1454  bool doMapping, unsigned baseIndex, CorrelatorType type, AstroBandInfo* info);
1455 
1456  // Map one or more antenna IFs to one or more switch channels
1457 
1458  void hardwareMapAntennaIFToSwitch(std::string antennaIFSpec, std::string switchChannelSpec);
1459 
1460 
1461  // Map a set of antenna IFs to a set of digitizers
1462 
1463  void hardwareMapAntennaIFToDigitizer(std::string antennaIFSpec, std::string digSpec);
1464 
1465  // Map one or more antenna IFs to one or more block
1466  // downconverter inputs
1467 
1468  void mapAntennaIFToBdc(std::string antennaIFSpec, std::string bdcSpec,
1469  bool doMapping=true, unsigned baseIndex=0, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1470 
1471  // Map a set of antenna IFs to a set of correlator crates
1472 
1473  void mapAntennaIFToCorr(std::string antennaIFSpec, std::string corrSpec,
1474  bool doMapping=true, unsigned baseIndex=0, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1475 
1476 
1477  // Map a set of antenna IFs to a set of digitizers
1478 
1479  void mapAntennaIFToDigitizer(std::string antennaIFSpec, std::string digitizerSpec,
1480  bool doMapping=true, unsigned baseIndex=0, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1481 
1482  // Map one or more antenna IFs to one or more device inputs
1483  // (Block downconverter or correlator)
1484 
1485  void mapAntennaIFToInput(std::string antennaIFSpec, std::string inputSpec,
1486  bool doMapping=true, unsigned baseIndex=0, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1487 
1488  // Load a new configuration from a file
1489 
1490  void loadConfiguration(std::string fileName, std::string confName, std::string astroBandConfName);
1491 
1492  // Select a configuration by name
1493 
1494  void selectConfiguration(std::string confName, unsigned baseIndex=0, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1495  void selectAstroBandConfiguration(std::string confName, AstroBandInfo* info=0, CorrelatorType type=CORR_ALL);
1496 
1497  // Check a configuration
1498 
1499  void validateConfiguration(std::string confName, unsigned baseIndex=0, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1500  void validateConfiguration(SwitchyardConfiguration& conf, unsigned baseIndex=0, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1501 
1502  // Check an astro band configuration
1503 
1504  void validateAstroBandConfiguration(std::string confName, unsigned baseIndex=0, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1505  void validateAstroBandConfiguration(AstroBandConfiguration& conf, unsigned baseIndex=0, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1506 
1507  // Clear the currently-selected configuration
1508 
1509  void clearConfiguration(CorrelatorType type=CORR_ALL);
1510  void clearAstroBandConfiguration(unsigned bandNo, SubarrayId saId=SA_NONE, CorrelatorType type=CORR_ALL);
1511 
1512  // Set a walsh column for the named antenna
1513 
1514  void setWalshColumn(std::string antName, unsigned walshColNo);
1515 
1516  // Clear a walsh column assignment for the named antenna
1517 
1518  void clearWalshColumn(std::string antName);
1519 
1520  // Return true if the requested switch setting does not conflict with any current configuration
1521 
1522  bool canAssertSwitchPosition(SwitchSetting swSet);
1523 
1524  // Get the walsh column for an antenna (or all antennas if antNo=0)
1525 
1526  std::vector<WalshColumnAssignment> getWalshColumnAssignment(unsigned antNo=0);
1527 
1528  // Return a vector of all correlator crates associated with
1529  // this astroband
1530 
1531  std::vector<CorrelatorCrateSpec> getActiveCorrelatorCrates(CorrelatorType type=CORR_ALL);
1532 
1533  // Return a vector describing the inputs of the requested
1534  // correlator crate
1535 
1536  std::vector<CorrelatorCrateInputSpec> getCorrelatorCrateInputMap(CorrelatorCrateSpec crate);
1537 
1538  // Return a vector of correlator bands associated with this
1539  // astroband
1540 
1541  std::vector<CorrelatorBandSpec> getCorrelatorBands(unsigned astroBandNo);
1542 
1543  // Return a vector of all configured correlator bands associated
1544  // with the requested correlator
1545 
1546  std::vector<CorrelatorBandSpec> getActiveCorrelatorBands(CorrelatorType type=CORR_ALL);
1547 
1548  // Return a vector describing the inputs of the requested
1549  // correlator band
1550 
1551  std::vector<CorrelatorBandInputSpec> getCorrelatorBandInputMap(CorrelatorBandSpec band);
1552 
1553  // Return a vector of astro band numbers currently configured, by correlator type
1554 
1555  std::vector<unsigned> getActiveAstroBandNos(CorrelatorType type);
1556 
1557  // Return a vector of astro band numbers for which the named
1558  // configuration specifies a mapping
1559 
1560  std::vector<unsigned> getAstroBandNosForConfiguration(std::string confName,
1561  SubarrayId saId,
1562  CorrelatorType type);
1563 
1564  // Return a vector of antenna numbers required by this astro
1565  // band.
1566  //
1567  // If all==true, we return all antennas involved in this
1568  // astroband configuration.
1569  //
1570  // If all=false, we return only antennas involved in this
1571  // astroband that currently belong to the subarray controlling
1572  // that astroband
1573 
1574  std::vector<AntennaSpec> getAntennas(unsigned astroBandNo, bool all=true);
1575 
1576  // Return a list of unique polarization states occurring in the
1577  // requested astroband.
1578  //
1579  // If all=true, return unique polarizations of any antenna occurring
1580  // in this astroband.
1581  //
1582  // If all=false, return unique polarizations only of antennas
1583  // currently belonging to the subarray controlling this
1584  // astroband
1585 
1586  std::vector<PolarizationType>
1587  getPolarizations(unsigned astroBandNo, bool all);
1588 
1589  // Get a reference to a named configuration
1590 
1591  SwitchyardConfiguration& getConfiguration(std::string name);
1592 
1593  // Add a configuration to the list of known configurations
1594 
1595  void addConfiguration(SwitchyardConfiguration& conf, std::string confName, std::string astroBandConfName);
1596 
1597  // Get a reference to a named astro band configuration
1598 
1599  AstroBandConfiguration& getAstroBandConfiguration(std::string name);
1600 
1601  // Add an astro band configuration to the list of known astro band configurations
1602 
1603  void addAstroBandConfiguration(std::string name, AstroBandConfiguration& conf);
1604 
1605  // Query switch settings for the current configuration
1606 
1607  std::vector<SwitchSetting>
1608  getIFSwitchSettings(unsigned astroBandNo=0);
1609 
1610  // Query block downconverter settings for the requested astroband
1611 
1612  std::vector<BlockDownconverterSetting>
1613  getBdcSettings(unsigned astroBandNo=0);
1614 
1615  // Query the walsh column for a given antenna
1616 
1617  unsigned getWalshColumn(unsigned antNo);
1618 
1619  // Print operators
1620 
1621  std::string printDown();
1622  std::string printUp();
1623 
1624  std::string printDownAntenna(std::string antName);
1625  std::string printDownSwitch(std::string switchName);
1626 
1627  static std::string fill(char fillChar, unsigned nChar);
1628 
1629  // Declare print function to be friend, for internal access to
1630  // class members
1631 
1632  friend std::ostream& operator<<(std::ostream& os, const SignalPathMap& swMap);
1633 
1634  private:
1635 
1636  // A vector of correlators
1637 
1638  std::vector<Correlator*> correlators_;
1639  std::map<CorrelatorType, Correlator*> correlatorMap_;
1640 
1641  std::vector<FpgaBoard*> fpgaBoards_;
1642 
1643  // A vector of hardware switches
1644 
1645  std::vector<Switch*> switches_;
1646 
1647  // A map of switches by name
1648 
1649  std::map<std::string, Switch*> switchMap_;
1650 
1651  // A vector of antennas
1652 
1653  std::vector<Antenna*> antennas_;
1654 
1655  // A map of antennas by name
1656 
1657  std::map<std::string, Antenna*> antennaMap_;
1658 
1659  // A vector of block downconverters
1660 
1661  std::vector<BlockDownconverter*> bdcs_;
1662 
1663  // A map of block downconverters by name
1664 
1665  std::map<std::string, BlockDownconverter*> bdcMap_;
1666 
1667  // A vector of correlator crates
1668 
1669  std::vector<CorrelatorCrate*> crates_;
1670 
1671  // A map of correlator crates by name
1672 
1673  std::map<std::string, CorrelatorCrate*> crateMap_;
1674 
1675  // A vector of astro bands
1676 
1677  std::vector<AstroBand*> astroBands_;
1678 
1679  // A map of astro bands by band number
1680 
1681  std::map<unsigned, AstroBand*> astroBandMap_;
1682 
1683  // A vector of correlator bands, for backwards compatibility
1684  // with CARMA control system nomenclature
1685 
1686  std::vector<CorrelatorBand*> corrBands_;
1687 
1688  // A map of correlator bands by name
1689 
1690  std::map<std::string, CorrelatorBand*> corrBandMap_;
1691 
1692  // A vector of digitizers
1693 
1694  std::vector<Digitizer*> digitizers_;
1695 
1696  // A map of correlator crates by name
1697 
1698  std::map<std::string, Digitizer*> digitizerMap_;
1699 
1700  // Private masks of walsh columns currently in use on each correlator
1701 
1702  unsigned walshColMaskSl_;
1703  unsigned walshColMaskWb_;
1704  unsigned walshColMaskC3g_;
1705 
1706  // An array of known configurations
1707 
1708  std::map<std::string, SwitchyardConfiguration> knownConfigurations_;
1709 
1710  // An array of known AstroBand configurations
1711 
1712  std::map<std::string, AstroBandConfiguration> knownAstroBandConfigurations_;
1713 
1714  void setWalshColumn(Antenna* ant, unsigned walshColNo);
1715  void clearWalshColumnMask(CorrelatorType type=CORR_ALL);
1716  void addToWalshColumnMask(WalshColumn& wf, CorrelatorType type);
1717  bool isSetInWalshColumnMask(WalshColumn& wf, CorrelatorType type);
1718  unsigned& getWalshColMask(CorrelatorType type);
1719  unsigned getNextUniqueWalshColNo(CorrelatorType type);
1720 
1721  void propagateWalshColumnAssignment(Antenna* antProp);
1722  void propagateWalshColumnAssignment(Antenna* antProp, unsigned walshColNo);
1723  void propagateWalshColumnAssignmentToCrates(Antenna* antProp, unsigned walshColNo);
1724  void propagateWalshColumnAssignmentToBands(Antenna* antProp, unsigned walshColNo);
1725 
1726  void assignFreeWalshColumns();
1727  void assignFreeWalshColumnsToCrates();
1728  void assignFreeWalshColumnsToBands();
1729 
1730  void assignHardwiredWalshColumns();
1731  void assignHardwiredCorrelatorWalshColumns();
1732  void assignHardwiredAntennaWalshColumns();
1733 
1734  void clearWalshColumns(CorrelatorType type=CORR_ALL);
1735  void clearWalshColumnsFromCrates(CorrelatorType type=CORR_ALL);
1736  void clearWalshColumnsFromBands(CorrelatorType type=CORR_ALL);
1737 
1738  void configureWalshColumns();
1739 
1740  // Methods used to initialize hardware mappings maintained by this class
1741 
1742  void initializeAntennaMap();
1743  void initializeSwitchMap();
1744  void initializeCrateMap();
1745  void initializeDigitizerMap();
1746  void initializeCorrelatorMap();
1747  void initializeFpgaBoardMap();
1748 
1749  void initializeAstroBands();
1750 
1751  void associateBdcBandsAndCrates();
1752  void mapBdcBandToCrate(BlockDownconverter* bdc, Band* band);
1753 
1754  // Methods used to manage the cable connections between hardware
1755 
1756  void initializeDefaultCableMap();
1757  void clearCableMap();
1758 
1759  // Initialize known valid configurations
1760 
1761  void initializeKnownConfigurations();
1762 
1763  std::string listUnconflictedConfigurations(CorrelatorType type, AstroBandInfo& info);
1764 
1765  // Individual methods to add known valid configurations
1766 
1767  void addLLConfiguration();
1768  void addRRConfiguration();
1769  void addCarma23Configuration();
1770  void addFullStokesConfiguration();
1771 
1772  // Initialize known valid FPGA configurations
1773 
1774  void initializeKnownAstroBandConfigurations();
1775 
1776  // Individual methods to add known valid FPGA configurations
1777 
1778  void addSingleAstroBandConfiguration();
1779  void addCarma23AstroBandConfiguration();
1780  void addFullStokesAstroBandConfiguration();
1781  void addDualPolAstroBandConfiguration();
1782 
1783  public:
1784 
1785  // Internal method to assert an antenna IF to switch channel mapping
1786 
1787  void hardwareMapAntennaIFToSwitch(unsigned carmaId, PolarizationType type, SplitterChannelId splitterChannel,
1788  unsigned switchId, SwitchChannelId switchChannel);
1789 
1790 
1791  // Internal method to assert an antenna IF to digitizer mapping
1792 
1793  void hardwareMapAntennaIFToDigitizer(unsigned carmaId, PolarizationType type, SplitterChannelId splitterChannelId,
1794  std::string digitizerId);
1795 
1796  // Internal method to assert an antenna IF to BlockDownconverter
1797  // mapping
1798 
1799  void mapAntennaIFToBdc(unsigned carmaId, PolarizationType polType, SplitterChannelId scId,
1800  unsigned bdcIndex, std::vector<unsigned>& bandIndices,
1801  bool doMapping=true, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1802 
1803  void mapAntennaIFToBdc(unsigned carmaId, PolarizationType polType, SplitterChannelId scId,
1804  unsigned bdcIndex, unsigned bandNo,
1805  bool doMapping=true, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1806 
1807  // Internal method to assert an antenna IF to
1808  // CorrelatorCrateInput mapping
1809 
1810  void mapAntennaIFToCorr(unsigned carmaId, PolarizationType polType, SplitterChannelId scId,
1811  std::string crateName, unsigned inputIndex,
1812  bool doMapping=true, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1813 
1814  // Internal method to assert an antenna IF to
1815  // Digitizer mapping
1816 
1817  void mapAntennaIFToDigitizer(unsigned carmaId, PolarizationType polType, SplitterChannelId scId,
1818  std::string digitizerName,
1819  bool doMapping=true, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1820 
1821  // Internal method to assert a CorrelatorCrateInput to
1822  // AstroBandInput mapping
1823 
1824  void mapCorrInputToAstroBandInput(std::string crateName, unsigned crateInputNo,
1825  unsigned astroBandNo, unsigned astroBandInputNo,
1826  bool doMapping=true, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1827 
1828  // Map a single correlator band input to an astro band input
1829 
1830  void mapBandInputToAstroBandInput(std::string bandName, unsigned bandInputNo,
1831  unsigned astroBandNo, unsigned astroBandInputNo,
1832  bool doMapping, CorrelatorType type, AstroBandInfo* info);
1833 
1834  // Internal method to assert a Digitizer to AstroBandInput mapping
1835 
1836  void mapDigitizerToAstroBandInput(std::string digId,
1837  unsigned astroBandNo, unsigned astroBandInputNo,
1838  bool doMapping=true, CorrelatorType type=CORR_ALL, AstroBandInfo* info=0);
1839 
1840  // Check an antenna IF to BlockDownconverter mapping without asserting it
1841 
1842  void validateAntennaIFToBdcMapping(std::string ifSpec, std::string bdcSpec, unsigned baseIndex=0);
1843 
1844  // Check an antenna IF to CorrelatorCrateInput mapping without asserting it
1845 
1846  void validateAntennaIFToCorrMapping(std::string ifSpec, std::string corrSpec, unsigned baseIndex=0);
1847 
1848  // Check an antenna IF to input mapping without asserting it
1849 
1850  void validateAntennaIFToInputMapping(std::string ifSpec, std::string inputSpec, unsigned baseIndex=0);
1851 
1852  // Accessor method for a correlator
1853 
1854  Correlator* getCorrelator(CorrelatorType type);
1855 
1856  // Accessor method for an antenna
1857 
1858  Antenna* getAntenna(std::string antName);
1859  Antenna* getAntenna(unsigned antNo);
1860  void validateAntenna(std::string antName);
1861  void validateAntenna(unsigned antNo);
1862 
1863  // Accessor method for an astro band
1864 
1865  AstroBand* getAstroBand(unsigned astroBandNo);
1866  void validateAstroBand(unsigned astroBandNo);
1867 
1868  // Accessor method for a block downconverter
1869 
1870  BlockDownconverter* getBdc(std::string antName);
1871  BlockDownconverter* getBdc(unsigned bdcNo);
1872  void validateBdc(std::string bdcName);
1873  void validateBdc(unsigned bdcNo);
1874 
1875  // Accessor methods for a crate
1876 
1877  CorrelatorCrate* getCrate(std::string crateName);
1878  CorrelatorCrate* getCrate(CorrelatorType type, unsigned crateNo);
1879  CorrelatorBand* getCorrBand(CorrelatorType type, unsigned bandNo);
1880  CorrelatorBand* getCorrBand(std::string bandName);
1881 
1882  void validateCrate(std::string crateName);
1883  void validateCorrBand(std::string bandName);
1884 
1885  // Accessor methods for a switch
1886 
1887  Switch* getSwitch(unsigned switchNo);
1888  Switch* getSwitch(std::string switchName);
1889  void validateSwitch(std::string switchName);
1890 
1891  // Accessor methods for a digitizer
1892 
1893  Digitizer* getDigitizer(std::string digitizerName);
1894  Digitizer* getDigitizer(unsigned digitizerNo);
1895  void validateDigitizer(std::string digitizerName);
1896 
1897  std::vector<SplitterChannelId>
1898  getDefaultSplitterChannelsForPolarization(PolarizationType type);
1899 
1900  //-----------------------------------------------------------------------
1901  // Utility functions used in mapping antenna IFs
1902  //-----------------------------------------------------------------------
1903 
1904  void checkArguments(unsigned carmaId, PolarizationType type, SplitterChannelId splitterChannel,
1905  unsigned switchId, SwitchChannelId switchChannel);
1906 
1907  void checkArguments(unsigned carmaId, PolarizationType type, SplitterChannelId splitterChannel,
1908  std::string digitizerId);
1909 
1910  void parseAstroBandSpecification(std::string astroSpec,
1911  std::vector<unsigned>& astroBandIndices, std::vector<unsigned>& astroBandInputIndices,
1912  unsigned baseIndex, bool actualIndex);
1913 
1914  void parseCorrBandSpecification(std::string bandSpec,
1915  std::vector<std::string>& bandNames,
1916  std::vector<unsigned>& inputIndices,
1917  unsigned baseIndex,
1918  bool actualIndex);
1919 
1920  void parseIfSpecification(std::string ifSpec, PolarizationType& type,
1921  std::vector<unsigned>& carmaIds, std::vector<SplitterChannelId>& channels);
1922 
1923  void parseSwitchSpecification(std::string switchSpec,
1924  std::vector<unsigned>& switchIds, std::vector<SwitchChannelId>& channels);
1925 
1926  void parseDigitizerSpecification(std::string digSpec, std::vector<std::string>& digIds,
1927  unsigned baseIndex=0, bool actualIndex=true);
1928 
1929  void parseBdcSpecification(std::string bdcSpec, std::vector<unsigned>& bdcIndices, std::vector<unsigned>& bandIndices,
1930  unsigned baseIndex=0, bool actualIndex=true);
1931 
1932  void parseCorrSpecification(std::string corrSpec, std::vector<std::string>& crateNames, std::vector<unsigned>& inputIndices,
1933  unsigned baseIndex=0, bool actualIndex=true);
1934 
1935  std::vector<unsigned> extractIndexRange(sza::util::String& antStr, unsigned lowestValid, unsigned highestValid,
1936  unsigned baseIndex=0, bool actualIndex=true);
1937 
1938  unsigned parseIndexExpression(sza::util::String& str,
1939  unsigned baseIndex, unsigned actualIndex,
1940  unsigned lowestValid, unsigned highestValid);
1941 
1942  void parseIndexOperands(sza::util::String& str, unsigned& op1, unsigned& op2, std::string op,
1943  unsigned baseIndex, unsigned actualIndex,
1944  unsigned lowestValid, unsigned highestValid);
1945 
1946  void addIndex(std::vector<unsigned>& indices, unsigned index, unsigned lowestValid, unsigned highestValid);
1947 
1948  unsigned firstEvenIndex(unsigned lowestValid, unsigned highestValid);
1949  unsigned firstOddIndex(unsigned lowestValid, unsigned highestValid);
1950 
1951  static SplitterChannelId splitterChannelNumberToChannelId(unsigned iChan);
1952  static SwitchChannelId switchChannelNumberToChannelId(unsigned iChan);
1953  static unsigned switchChannelIdToChannelNumber(SwitchChannelId);
1954  static signalpath::CorrelatorType corrNameToCorrType(std::string name);
1955  static std::string corrTypeAndCrateNoToCrateName(CorrelatorType type, unsigned crateNo);
1956  static std::string corrTypeAndBandNoToCorrBandName(CorrelatorType type, unsigned bandNo);
1957  static std::string antNoToAntName(unsigned antNo);
1958 
1959  }; // End class SignalPathMap
1960 
1961  //-----------------------------------------------------------------------
1962  // Print methods for SignalPathMap and associated classes
1963  //-----------------------------------------------------------------------
1964 
1965  std::ostream& operator<<(std::ostream& os, const Antenna& ant);
1966  std::ostream& operator<<(std::ostream& os, const AntennaIF& antIf);
1967 
1968  std::ostream& operator<<(std::ostream& os, const Switch& sw);
1969  std::ostream& operator<<(std::ostream& os, const SwitchChannel& swChan);
1970 
1971  std::ostream& operator<<(std::ostream& os, const BlockDownconverterInput& bdcInput);
1972 
1973  std::ostream& operator<<(std::ostream& os, const CorrelatorType& corrType);
1974 
1975  std::ostream& operator<<(std::ostream& os, const SignalPathMap& swMap);
1976 
1977  std::ostream& operator<<(std::ostream& os, const WalshColumn& wc);
1978 
1979  std::ostream& operator<<(std::ostream& os, ConnectableNode& node);
1980 
1981  std::ostream& operator<<(std::ostream& os, const AstroBandInput& input);
1982 
1983  std::ostream& operator<<(std::ostream& os, const CorrelatorBandInput& input);
1984 
1985  std::ostream& operator<<(std::ostream& os, const Digitizer& dig);
1986 
1987  std::ostream& operator<<(std::ostream& os, const FpgaBoard& brd);
1988 
1989  } // End namespace signalpath
1990 } // End namespace carma
1991 
1992 
1993 
1994 #endif // End #ifndef CARMA_SWITCHYARD_SIGNALPATHMAP_H
Base-class to encapsulate a connectable node.
Tagged: Tue Mar 6 16:39:02 PST 2012.
Class to encapsulate a device that can be configured, and therefore associated with multiple configur...
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
AntennaType
Enumeration of possible types for antennas.
ConfigurableDevice()
Default constructor.
Class to encapsulate a correlator crate.
Class to encapsulate a device that can be configured, and therefore associated with a configuring Ast...
Class to encapsulate a correlator.
Tagged: Wed May 12 09:30:13 PDT 2004.