From 91fbb2445be72ea9ee0e38ab1004821c1c8d90df Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Fri, 4 May 2018 08:56:09 +0000
Subject: [PATCH] Task #0: Throw an exception if FE is combined with CS/IS,
 which we do not support.

---
 RTCP/Cobalt/CoInterface/src/Parset.cc | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/RTCP/Cobalt/CoInterface/src/Parset.cc b/RTCP/Cobalt/CoInterface/src/Parset.cc
index 42a383800ad..35ae49eb9d6 100644
--- a/RTCP/Cobalt/CoInterface/src/Parset.cc
+++ b/RTCP/Cobalt/CoInterface/src/Parset.cc
@@ -704,6 +704,12 @@ namespace LOFAR
         size_t incoherent_idx = 0;
 
         // Parse all TABs
+        //
+        // Strategy:
+        //     * If Fly's Eye is enabled, we have 1 TAB/station. Do NOT process any other TABs.
+        //     * If Fly's Eye is disabled, process TABs in this order:
+        //                1. Manually specified TABs (Observation.Beam[x].TiedArrayBeam[y]
+        //                2. TAB rings (Observation.Beam[x].nrTabRings)
         settings.beamFormer.SAPs.resize(nrSAPs);
 
         for (unsigned i = 0; i < nrSAPs; ++i) 
@@ -720,12 +726,22 @@ namespace LOFAR
           size_t nrRings   = getUint32(str(format("Observation.Beam[%u].nrTabRings") % i), 0);
           double ringWidth = getDouble(str(format("Observation.Beam[%u].tabRingSize") % i), 0.0);
 
+          // Throw if we encounter an unsupported configuration
+          if (settings.beamFormer.doFlysEye) {
+            if (nrRings > 0 || nrTABSParset > 0) {
+              THROW(CoInterfaceException, "Cannot produce (in)coherent TABs in Fly's Eye mode. Error detected in SAP " << i << ".");
+            }
+          }
+
           // Create a ptr to RingCoordinates object
           // If there are tab rings the object will be actuall constructed
           // The actual tabs will be extracted after we added all manual tabs
           // But we need the number of tabs from rings at this location
           std::auto_ptr<RingCoordinates> ptrRingCoords;
-          if (nrRings > 0) {
+          if (settings.beamFormer.doFlysEye) {
+            // For Fly's Eye mode we have exactly one TAB per antenna field.
+            nrTABs = settings.antennaFields.size();
+          } else if (nrRings > 0) {
             const string prefix = str(format("Observation.Beam[%u]") % i);
             string directionType = getString(prefix + ".directionType", "J2000");
             
@@ -746,9 +762,6 @@ namespace LOFAR
             // Increase the amount of tabs with the number from the coords object
             // this might be zero
             nrTABs = nrTABSParset + ptrRingCoords->nCoordinates();
-          } else if (settings.beamFormer.doFlysEye) {
-            // For Fly's Eye mode we have exactly one TAB per antenna field.
-            nrTABs = settings.antennaFields.size();
           }
 
           sap.TABs.resize(nrTABs);
@@ -758,6 +771,7 @@ namespace LOFAR
             // Add flys eye tabs
             if (settings.beamFormer.doFlysEye) 
             {
+              // Copy direction from SAP
               const string prefix = str(format("Observation.Beam[%u]") % i);
 
               tab.direction.type    = getString(prefix + ".directionType", "J2000");
-- 
GitLab